From a1e85363447e06c0d60f859ae96068e4be270e46 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Fri, 20 Nov 2026 17:48:23 +0100 Subject: [PATCH 1/2] upstreaming: keep sibling workflow repairs in scope --- SESSIONLOG.md | 1 + upstreaming/INTEGRATION.md | 6 +++++- upstreaming/common.py | 13 +++++++++++++ upstreaming/reconcile.py | 21 +++++++++++++++++++-- upstreaming/tests/test_observation.py | 10 +++++++++- 5 files changed, 47 insertions(+), 4 deletions(-) diff --git a/SESSIONLOG.md b/SESSIONLOG.md index 76a643ff4551..a0eb9657cd61 100644 --- a/SESSIONLOG.md +++ b/SESSIONLOG.md @@ -23,3 +23,4 @@ - 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. +- After the pipeline correctly reported spookyhash repair blocked by exact-file scope, normalized approved workflow scope to `.github/workflows/*` and added a revisioned migration for idle repair records so sibling test/build workflows remain pipeline-repairable. diff --git a/upstreaming/INTEGRATION.md b/upstreaming/INTEGRATION.md index b9c675484fa3..405ccf4875ff 100644 --- a/upstreaming/INTEGRATION.md +++ b/upstreaming/INTEGRATION.md @@ -187,7 +187,11 @@ 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. +revisioned development repair. When a dossier approves any file under +`.github/workflows/`, the admitted scope is normalized to the bounded +`.github/workflows/*` glob so review and CI repair can update a sibling test, +build, or release workflow. Existing publisher checks still reject unsafe +workflow content and every non-workflow path remains explicitly scoped. Previously merged implementation: diff --git a/upstreaming/common.py b/upstreaming/common.py index cb3aea29724e..8fb1ee5b1501 100644 --- a/upstreaming/common.py +++ b/upstreaming/common.py @@ -83,6 +83,19 @@ def validate_scope_paths(paths: list[str]) -> list[str]: return paths +def normalize_workflow_scope(paths: list[str]) -> list[str]: + """Use one bounded workflow-directory scope when any workflow is approved. + + Architecture integration and its test/release validation commonly span + sibling workflow files. Exact-file scope strands review-driven repair, while + the publisher still applies its workflow-content safety policy to this glob. + """ + result = [path for path in paths if not path.startswith(".github/workflows/")] + if len(result) != len(paths): + result.insert(0, ".github/workflows/*") + return validate_scope_paths(list(dict.fromkeys(result))) + + def normalize_distribution(name: str) -> str: """PEP 503 name normalization.""" return re.sub(r"[-_.]+", "-", name).lower() diff --git a/upstreaming/reconcile.py b/upstreaming/reconcile.py index afc1a2c83e3e..ca5ff2ff081d 100644 --- a/upstreaming/reconcile.py +++ b/upstreaming/reconcile.py @@ -27,7 +27,7 @@ from typing import Any from . import capacity, collect, controller, lifecycle, observe_ci, recovery, schemas -from .common import safe_id +from .common import normalize_workflow_scope, safe_id @dataclass @@ -277,7 +277,7 @@ def apply_publication(rec: dict, outcome: dict, *, now: str, policy: dict | None new["phase"] = "provisioning" new["activity"] = "idle" new["admission_class"] = dossier["proposal"]["admission_class"] - new["scope_paths"] = list(dossier["proposal"]["allowed_paths"]) + new["scope_paths"] = normalize_workflow_scope(list(dossier["proposal"]["allowed_paths"])) new["pending_human_action"] = None new["revision"] += 1 staged.append(("events", lifecycle._event(rec, new, "dossier_develop", "observation", @@ -491,6 +491,23 @@ def numeric(value): contributions[key] = c out.staged.append(("contributions", c)) + # Exact workflow-file scopes from older dossiers cannot absorb review or + # CI fixes in sibling workflows. Migrate only idle repair records. Active + # immutable Work finishes through normal terminal recovery first. + for key, c in list(contributions.items()): + paths = c.get("scope_paths") or [] + widened = normalize_workflow_scope(paths) if paths else paths + if widened != paths and c["activity"] == "fix_needed" and not c.get("active_work") \ + and c["phase"] in {"development", "handoff", "upstream_review"}: + before = c + c = dict(c, scope_paths=widened, revision=c["revision"] + 1, + clean_head_sha=None, handoff_request=None, handoff_approval=None, + updated_at=iso) + contributions[key] = c + out.staged.append(("contributions", c)) + out.staged.append(("events", lifecycle._event( + before, c, "workflow_scope_normalized", "migration", None, iso, True))) + # 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/tests/test_observation.py b/upstreaming/tests/test_observation.py index fc9ea47e424e..20ce15563412 100644 --- a/upstreaming/tests/test_observation.py +++ b/upstreaming/tests/test_observation.py @@ -8,7 +8,7 @@ from datetime import datetime, timedelta, timezone from pathlib import Path -from upstreaming import (capacity, ci_evidence, collect, commands, controller, recovery, +from upstreaming import (capacity, ci_evidence, collect, commands, common, controller, recovery, release, triggers) from upstreaming.tests.helpers import (NOW, OWNER, SHA_A, SHA_B, comment, contribution, policy) @@ -255,6 +255,14 @@ def test_only_new_authorized_current_head_review_feedback_is_returned(self): self.assertIsNone(collect.development_review_feedback(self.Api(), rec, [OWNER["id"]])) +class TestScopeNormalization(unittest.TestCase): + def test_workflow_files_share_a_bounded_repair_scope(self): + self.assertEqual(common.normalize_workflow_scope([ + ".github/workflows/wheels.yml", "README.rst", ".github/workflows/test.yml"]), + [".github/workflows/*", "README.rst"]) + self.assertEqual(common.normalize_workflow_scope(["src/port.c"]), ["src/port.c"]) + + class TestTriggers(unittest.TestCase): def test_semantics(self): doc = {"on": {"push": {"branches": ["main"], "paths": ["docs/**", "!docs/x/**"]}}} From 60822210735a9d13c47af48448cb8f345f028f3a Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Fri, 20 Nov 2026 18:07:25 +0100 Subject: [PATCH 2/2] upstreaming: derive complete scope and extend it from review --- .../upstreaming-investigator.lock.yml | 2 +- .github/workflows/upstreaming-investigator.md | 16 +++++++-- .github/workflows/upstreaming-worker.lock.yml | 2 +- .github/workflows/upstreaming-worker.md | 9 ++++- SESSIONLOG.md | 2 +- upstreaming/INTEGRATION.md | 16 ++++++--- upstreaming/README.md | 12 +++++-- upstreaming/__main__.py | 7 ++-- upstreaming/common.py | 13 ------- upstreaming/dossier_gate.py | 16 +++++++++ upstreaming/fork_publish.py | 27 +++++++++++--- upstreaming/reconcile.py | 25 ++++--------- upstreaming/schemas/dossier.schema.json | 14 +++++++- upstreaming/schemas/operation.schema.json | 4 +++ upstreaming/tests/test_dossier_gate.py | 36 ++++++++++++++++++- upstreaming/tests/test_fork_publish.py | 28 +++++++++++++-- upstreaming/tests/test_observation.py | 12 ++----- upstreaming/tests/test_pipeline.py | 7 ++++ upstreaming/work.py | 2 ++ 19 files changed, 183 insertions(+), 67 deletions(-) diff --git a/.github/workflows/upstreaming-investigator.lock.yml b/.github/workflows/upstreaming-investigator.lock.yml index 92d0284bb28b..abc4dddcd5a4 100644 --- a/.github/workflows/upstreaming-investigator.lock.yml +++ b/.github/workflows/upstreaming-investigator.lock.yml @@ -1,4 +1,4 @@ -# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"221d65bee18fc708430267f76f7674cd1ee3eac1223ed5597b42958f6b36f98a","body_hash":"285b0539b219b7894a4c0dbdfe646247aecbe7311a753523e2953081cdd4b864","compiler_version":"v1.2.2","agent_id":"pi","agent_model":"anthropic/claude-sonnet-5-5","engine_versions":{"pi":"1.5.0"}} +# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"221d65bee18fc708430267f76f7674cd1ee3eac1223ed5597b42958f6b36f98a","body_hash":"7c1737a5a28360a69072cb16e8d8159ae11f6edd17bb9f537b4031713c8f25ed","compiler_version":"v1.2.2","agent_id":"pi","agent_model":"anthropic/claude-sonnet-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"],"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-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"},{"image":"ghcr.io/riseproject-dev/sw-ecosystem/project-graph-mcp:latest"}],"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_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":"project-graph","tools":["project_graph_query"]},{"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":"disabled"},"admission":false,"work_queue":{"worker":true,"logical_contract":"326b3240d146cc134cfc7c2345af10f216fffde999dc581fc45af17237e649a8"},"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-investigator.md b/.github/workflows/upstreaming-investigator.md index e4d4f8f5361e..99274202fee5 100644 --- a/.github/workflows/upstreaming-investigator.md +++ b/.github/workflows/upstreaming-investigator.md @@ -446,7 +446,16 @@ call: `{"path": "upstreaming-out"}` (the native handler names the artifact for `park`; - `allowed_paths`: 1..32 exact relative paths or directory globs with a single final wildcard component for `develop`, and an empty list for - `park`. Never use `*`, `**`, absolute paths, `.git`, or `..`. + `park`. Never use `*`, `**`, absolute paths, `.git`, or `..`; + - `path_coverage`: exactly one assessment for each of `build`, `test`, + `release`, `packaging`, `documentation`, and `native_sources`. Each entry + lists every repository path that may need a riscv64 change in that area, + or an empty path list with a source-grounded explanation. For `develop`, + every listed path must be matched by `allowed_paths`. Inspect sibling + workflows, called reusable workflows, action files, build configuration, + package metadata, native source dispatch, support documentation, artifact + validation, and release/publish consumers. Do not scope only the first file + that appears sufficient. A `develop` decision automatically provisions the fork and starts development; it does not wait for scope approval. A `park` decision stops work but can be @@ -468,7 +477,10 @@ call: `{"path": "upstreaming-out"}` (the native handler names the artifact that stop CI from running on a fork; - contribution rules: CONTRIBUTING, commit conventions, CLA/DCO; - any existing riscv64 work upstream (issues, PRs, CI); - - proposed admission class, allowed paths, target matrix, and risks. + - proposed admission class, complete multi-path coverage, allowed paths, + target matrix, and risks. Trace the full build-to-test-to-release graph and + include all files that may require modification, even when the initial + patch is expected to touch only a subset. - `proposal.json`: a JSON object matching `upstreaming/schemas/proposal.schema.json` in the control repository, with `outcome: "investigation"`, `operation: "none"`, and diff --git a/.github/workflows/upstreaming-worker.lock.yml b/.github/workflows/upstreaming-worker.lock.yml index fb01aec33d8a..a656ff95f7d2 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":"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-metadata: {"schema_version":"v4","frontmatter_hash":"30088af59ad86726a3c2b0b6b6076ec9463412481ddfd3a12da5d807b699c00a","body_hash":"19b4705095d742dc2c1c10ff72b468f2cb470e4b3a11bf80a9a4deac6ee4b7f4","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 27372c9699ac..d9001fb6f7eb 100644 --- a/.github/workflows/upstreaming-worker.md +++ b/.github/workflows/upstreaming-worker.md @@ -311,7 +311,14 @@ re-applies your series in a fresh repository, validates it against the approved scope and pushes it to `riscv64` itself. Anything outside `allowed_paths`, any `{debug}` commit when `upstream_facing` is true, any `pull_request_target`, new secret, or interpolation of untrusted event text into -scripts is rejected. +scripts is rejected. For a repair backed by authorized review feedback, +`review_scope_extension` is true. Natural-language review feedback may require +an exact file that the original dossier missed. Research the request, include +that exact repository-relative path in `changed_files`, and make the requested +change without asking the reviewer to use command syntax. The trusted publisher +will admit only the exact changed paths in this repair and persist verified +additions to contribution scope. This does not permit globs or unrelated files. +Inline review comment paths are present in the human-relay evidence data. ## Mandatory change-history research diff --git a/SESSIONLOG.md b/SESSIONLOG.md index a0eb9657cd61..17561079778f 100644 --- a/SESSIONLOG.md +++ b/SESSIONLOG.md @@ -23,4 +23,4 @@ - 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. -- After the pipeline correctly reported spookyhash repair blocked by exact-file scope, normalized approved workflow scope to `.github/workflows/*` and added a revisioned migration for idle repair records so sibling test/build workflows remain pipeline-repairable. +- Replaced the rejected workflow-glob approach with complete dossier path coverage and natural-language review scope extension: human-relay-backed repairs may add exact changed paths, which trusted publication verifies and persists without requiring command syntax. diff --git a/upstreaming/INTEGRATION.md b/upstreaming/INTEGRATION.md index 405ccf4875ff..aa1f4315bdb8 100644 --- a/upstreaming/INTEGRATION.md +++ b/upstreaming/INTEGRATION.md @@ -187,11 +187,17 @@ 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. When a dossier approves any file under -`.github/workflows/`, the admitted scope is normalized to the bounded -`.github/workflows/*` glob so review and CI repair can update a sibling test, -build, or release workflow. Existing publisher checks still reject unsafe -workflow content and every non-workflow path remains explicitly scoped. +revisioned development repair. + +The investigation dossier assesses path coverage separately for build, test, +release, packaging, documentation and native sources. Its multi-path +`allowed_paths` must cover every path found by that assessment and is preserved +through contribution state, Work and publication. If an authorized reviewer +later asks in ordinary natural language for a change that requires another +file, the human-relay-backed repair may identify and change that additional +exact path without command syntax. The trusted publisher admits only exact +paths actually changed by that repair, applies all existing content and workflow +safety checks, and persists the verified paths into contribution scope. Previously merged implementation: diff --git a/upstreaming/README.md b/upstreaming/README.md index c45579821b24..c1bfb93dc73c 100644 --- a/upstreaming/README.md +++ b/upstreaming/README.md @@ -162,8 +162,10 @@ pilot details are kept in lifecycle state and diagnostic artifacts, not here. `notify` job posts a bounded readable summary to the tracking issue. The controller records the dossier as evidence. A machine-readable, trusted-gated dossier decision either moves directly to `provisioning` with a bounded - admission class and path set, or moves to `parked` when no concrete patch is - actionable. Neither route waits for scope approval. An authorized human may + admission class and multi-path set, or moves to `parked` when no concrete + patch is actionable. The dossier must separately assess build, test, release, + packaging, documentation and native-source paths, and its allowed path set + must cover every path found. Neither route waits for scope approval. An authorized human may override a parked decision with: ```text @@ -210,7 +212,11 @@ pilot details are kept in lifecycle state and diagnostic artifacts, not here. and PR conversation comments from authorized reviewers. Feedback bound to the current head is persisted as `human_relay` evidence, processed once, and automatically starts a revisioned repair with the exact reviewer, URL, path, - line and text in task context. Passing means every required riscv64 job and + line and text in task context. Ordinary natural-language review feedback may + require another file without any command syntax. A human-relay-backed repair + may identify that exact path; trusted publication validates the actual diff + and persists the verified path into contribution scope. Passing means every + required riscv64 job and wheel artifact satisfy the project-specific frozen topology contract. 5. **Upstream handoff.** When the exact development head passes its frozen CI contract and has no debug commits, observation automatically records it as the diff --git a/upstreaming/__main__.py b/upstreaming/__main__.py index 61af285c769f..b020e513ee9f 100644 --- a/upstreaming/__main__.py +++ b/upstreaming/__main__.py @@ -200,8 +200,11 @@ def cmd_plan(args) -> int: for evidence_id in req.get("reason_ids") or []: evidence = snap.evidence.get(evidence_id) if evidence: - reason_evidence.append({key: evidence.get(key) for key in - ("evidence_id", "kind", "summary", "limitations")}) + item = {key: evidence.get(key) for key in + ("evidence_id", "kind", "summary", "limitations")} + if evidence.get("kind") == "human_relay": + item["data"] = evidence.get("data") + reason_evidence.append(item) nodes.append(work.node(req, rec, control_repo_id=args.control_repo_id, allowed_paths=rec.get("scope_paths") or ctr.get("allowed_paths") or [".github/workflows/*"], diff --git a/upstreaming/common.py b/upstreaming/common.py index 8fb1ee5b1501..cb3aea29724e 100644 --- a/upstreaming/common.py +++ b/upstreaming/common.py @@ -83,19 +83,6 @@ def validate_scope_paths(paths: list[str]) -> list[str]: return paths -def normalize_workflow_scope(paths: list[str]) -> list[str]: - """Use one bounded workflow-directory scope when any workflow is approved. - - Architecture integration and its test/release validation commonly span - sibling workflow files. Exact-file scope strands review-driven repair, while - the publisher still applies its workflow-content safety policy to this glob. - """ - result = [path for path in paths if not path.startswith(".github/workflows/")] - if len(result) != len(paths): - result.insert(0, ".github/workflows/*") - return validate_scope_paths(list(dict.fromkeys(result))) - - def normalize_distribution(name: str) -> str: """PEP 503 name normalization.""" return re.sub(r"[-_.]+", "-", name).lower() diff --git a/upstreaming/dossier_gate.py b/upstreaming/dossier_gate.py index c00e31d7a74e..1fa9640cc62a 100644 --- a/upstreaming/dossier_gate.py +++ b/upstreaming/dossier_gate.py @@ -8,6 +8,7 @@ """ from __future__ import annotations +import fnmatch import hashlib import json import os @@ -57,11 +58,26 @@ def validate(dossier: dict, proposal: dict, task: dict) -> None: if issue["url"] not in {s["url"] for s in dossier["research"]["tracking_issue"]["sources"]}: raise DossierError("tracking-issue research must cite the original issue URL") decision = dossier["proposal"] + coverage = decision["path_coverage"] + areas = [entry["area"] for entry in coverage] + required_areas = {"build", "test", "release", "packaging", "documentation", "native_sources"} + if set(areas) != required_areas or len(areas) != len(set(areas)): + raise DossierError("path_coverage must assess each required area exactly once") + covered_paths = [path for entry in coverage for path in entry["paths"]] + if covered_paths: + try: + validate_scope_paths(covered_paths) + except ValueError as exc: + raise DossierError(f"path_coverage: {exc}") from None if decision["decision"] == "develop": try: validate_scope_paths(decision["allowed_paths"]) except ValueError as exc: raise DossierError(str(exc)) from None + missing = [path for path in covered_paths if not any( + fnmatch.fnmatchcase(path, allowed) for allowed in decision["allowed_paths"])] + if missing: + raise DossierError(f"allowed_paths omit researched riscv64 paths: {sorted(set(missing))}") def _read(root: Path, relative: Path, limit: int = 256 * 1024) -> str: diff --git a/upstreaming/fork_publish.py b/upstreaming/fork_publish.py index cb960132efd6..54cf97573df8 100644 --- a/upstreaming/fork_publish.py +++ b/upstreaming/fork_publish.py @@ -30,6 +30,7 @@ from __future__ import annotations import base64 +import fnmatch import hashlib import json import os @@ -41,7 +42,7 @@ from typing import Callable from . import lifecycle, publisher, recovery, schemas -from .common import DEV_REF, FORK_ORG +from .common import DEV_REF, FORK_ORG, validate_scope_paths MAX_MBOX_BYTES = 4 * 1024 * 1024 _SHA = re.compile(r"^[0-9a-f]{40}$") @@ -229,13 +230,30 @@ def publish(*, record: dict, task: dict, proposal: dict, mbox: bytes, token: str if tree != proposal["proposed_tree"]: return Outcome("rejected", "rebuilt tree differs from the proposal's proposed_tree", candidate=cand, failure_class="validation") - sc = publisher.Scope(allowed_globs=scope.allowed_globs, workflow_globs=scope.workflow_globs, + claimed = set(proposal.get("changed_files") or []) + effective_globs = list(scope.allowed_globs) + outside_scope = sorted(path for path in claimed if not any( + fnmatch.fnmatchcase(path, allowed) for allowed in scope.allowed_globs)) + if outside_scope: + if not task.get("review_scope_extension"): + return Outcome("rejected", f"proposal changes files outside admitted scope: {outside_scope}", + candidate=cand, failure_class="validation") + if any(any(ch in path for ch in "*?[]") for path in outside_scope): + return Outcome("rejected", "review scope extensions must be exact paths", + candidate=cand, failure_class="validation") + try: + validate_scope_paths(outside_scope) + validate_scope_paths(list(dict.fromkeys(effective_globs + outside_scope))) + except ValueError as exc: + return Outcome("rejected", f"invalid review scope extension: {exc}", + candidate=cand, failure_class="validation") + effective_globs.extend(outside_scope) + sc = publisher.Scope(allowed_globs=effective_globs, workflow_globs=scope.workflow_globs, upstream_facing=record.get("upstream_pr") is not None, history="append" if proposal["operation"] == "append" else "rewrite") rep = publisher.validate_update(work, base=record["upstream"]["base_sha"], expected_head=expected, candidate=cand, scope=sc) delta = _git(work, "diff", "--name-only", "--no-renames", expected, cand).stdout.decode().split() - claimed = set(proposal.get("changed_files") or []) if claimed and set(delta) != claimed: rep.problems.append(f"proposal claims files {sorted(claimed)} but series changes {sorted(delta)}") digest = hashlib.sha256(mbox).hexdigest() @@ -256,7 +274,8 @@ def publish(*, record: dict, task: dict, proposal: dict, mbox: bytes, token: str "base_sha": record["upstream"]["base_sha"]}, proposed={"commit": cand, "tree": rep.final_tree, "parents": parents, "marker": f"artifact:{artifact['artifact_id']}" if artifact else None, - "content_digest": hashlib.sha256(mbox).hexdigest()}, now=now) + "content_digest": hashlib.sha256(mbox).hexdigest(), + "changed_files": delta}, now=now) save_operation(op) # intent persisted before the effect if policy.get("read_only", True): return Outcome("rejected", "policy is read-only; validated but not pushed", candidate=cand, diff --git a/upstreaming/reconcile.py b/upstreaming/reconcile.py index ca5ff2ff081d..70d8efaf1dd3 100644 --- a/upstreaming/reconcile.py +++ b/upstreaming/reconcile.py @@ -27,7 +27,7 @@ from typing import Any from . import capacity, collect, controller, lifecycle, observe_ci, recovery, schemas -from .common import normalize_workflow_scope, safe_id +from .common import safe_id @dataclass @@ -218,6 +218,10 @@ def apply_publication(rec: dict, outcome: dict, *, now: str, policy: dict | None staged.append(("operations", op)) new["publication_operation_id"] = op["operation_id"] status = outcome.get("status") + if status in ("published", "uncertain") and op: + changed_files = (op.get("proposed") or {}).get("changed_files") or [] + if changed_files: + new["scope_paths"] = list(dict.fromkeys((new.get("scope_paths") or []) + changed_files)) if status == "published": # The branch head itself is recorded by the next observation (head # change bumps revision); here we only leave agent_running. @@ -277,7 +281,7 @@ def apply_publication(rec: dict, outcome: dict, *, now: str, policy: dict | None new["phase"] = "provisioning" new["activity"] = "idle" new["admission_class"] = dossier["proposal"]["admission_class"] - new["scope_paths"] = normalize_workflow_scope(list(dossier["proposal"]["allowed_paths"])) + new["scope_paths"] = list(dossier["proposal"]["allowed_paths"]) new["pending_human_action"] = None new["revision"] += 1 staged.append(("events", lifecycle._event(rec, new, "dossier_develop", "observation", @@ -491,23 +495,6 @@ def numeric(value): contributions[key] = c out.staged.append(("contributions", c)) - # Exact workflow-file scopes from older dossiers cannot absorb review or - # CI fixes in sibling workflows. Migrate only idle repair records. Active - # immutable Work finishes through normal terminal recovery first. - for key, c in list(contributions.items()): - paths = c.get("scope_paths") or [] - widened = normalize_workflow_scope(paths) if paths else paths - if widened != paths and c["activity"] == "fix_needed" and not c.get("active_work") \ - and c["phase"] in {"development", "handoff", "upstream_review"}: - before = c - c = dict(c, scope_paths=widened, revision=c["revision"] + 1, - clean_head_sha=None, handoff_request=None, handoff_approval=None, - updated_at=iso) - contributions[key] = c - out.staged.append(("contributions", c)) - out.staged.append(("events", lifecycle._event( - before, c, "workflow_scope_normalized", "migration", None, iso, True))) - # 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/dossier.schema.json b/upstreaming/schemas/dossier.schema.json index e05cd6f77640..089ce762dc7c 100644 --- a/upstreaming/schemas/dossier.schema.json +++ b/upstreaming/schemas/dossier.schema.json @@ -89,7 +89,7 @@ "proposal": { "type": "object", "additionalProperties": true, - "required": ["decision", "rationale", "admission_class", "allowed_paths"], + "required": ["decision", "rationale", "admission_class", "allowed_paths", "path_coverage"], "properties": { "decision": {"enum": ["develop", "park"]}, "rationale": {"type": "string", "minLength": 40, "maxLength": 8000}, @@ -97,6 +97,18 @@ "allowed_paths": { "type": "array", "maxItems": 32, "items": {"type": "string", "minLength": 1, "maxLength": 200} + }, + "path_coverage": { + "type": "array", "minItems": 6, "maxItems": 6, + "items": { + "type": "object", "additionalProperties": false, + "required": ["area", "paths", "assessment"], + "properties": { + "area": {"enum": ["build", "test", "release", "packaging", "documentation", "native_sources"]}, + "paths": {"type": "array", "maxItems": 32, "items": {"type": "string", "minLength": 1, "maxLength": 200}}, + "assessment": {"type": "string", "minLength": 20, "maxLength": 4000} + } + } } }, "allOf": [ diff --git a/upstreaming/schemas/operation.schema.json b/upstreaming/schemas/operation.schema.json index 6fa4fc7e2734..9c599a535eb9 100644 --- a/upstreaming/schemas/operation.schema.json +++ b/upstreaming/schemas/operation.schema.json @@ -129,6 +129,10 @@ "string", "null" ] + }, + "changed_files": { + "type": "array", "maxItems": 32, + "items": {"type": "string", "minLength": 1, "maxLength": 500} } } }, diff --git a/upstreaming/tests/test_dossier_gate.py b/upstreaming/tests/test_dossier_gate.py index 4af41bfbea8a..6c965e5db80d 100644 --- a/upstreaming/tests/test_dossier_gate.py +++ b/upstreaming/tests/test_dossier_gate.py @@ -54,7 +54,15 @@ def dossier(): "prior_work_and_blockers": "Followed and reviewed the report's linked prior contributions and architecture blockers."}, "corroboration_and_conflicts": [ISSUE_URL]}, "proposal": {"decision": "develop", "rationale": "Add bounded wheel CI configuration following the verified architecture precedent.", - "admission_class": "configuration_integration", "allowed_paths": [".github/workflows/*"]}} + "admission_class": "configuration_integration", "allowed_paths": [".github/workflows/*", "README.rst"], + "path_coverage": [ + {"area": "build", "paths": [".github/workflows/wheels.yml"], "assessment": "The wheel workflow owns architecture build rows."}, + {"area": "test", "paths": [".github/workflows/test.yml"], "assessment": "The test matrix mirrors supported build architectures."}, + {"area": "release", "paths": [".github/workflows/release.yml"], "assessment": "The release workflow consumes validated wheel artifacts."}, + {"area": "packaging", "paths": [], "assessment": "Packaging metadata requires no architecture-specific change."}, + {"area": "documentation", "paths": ["README.rst"], "assessment": "The support table documents shipped architectures."}, + {"area": "native_sources", "paths": [], "assessment": "No architecture-specific native source dispatch exists."} + ]}} d["research"]["ecosystem_report"]["sources"][0]["url"] = REPORT_URL return d @@ -89,6 +97,16 @@ def test_development_decision_requires_bounded_scope_and_park_is_empty(self): with self.assertRaises(schemas.SchemaError): dossier_gate.validate(d, proposal(), task()) + def test_allowed_paths_cover_every_researched_riscv64_path(self): + d = dossier() + d["proposal"]["allowed_paths"] = [".github/workflows/wheels.yml", "README.rst"] + with self.assertRaisesRegex(dossier_gate.DossierError, "omit researched"): + dossier_gate.validate(d, proposal(), task()) + d = dossier() + d["proposal"]["path_coverage"][1]["area"] = "build" + with self.assertRaisesRegex(dossier_gate.DossierError, "each required area"): + dossier_gate.validate(d, proposal(), task()) + def test_every_category_is_required(self): for category in dossier_gate.RESEARCH_CATEGORIES: d = dossier() @@ -168,6 +186,22 @@ def test_symlinked_inputs_rejected(self): class TestImmutableTrackingIssue(unittest.TestCase): + def test_authorized_human_relay_enables_natural_review_scope_extension(self): + rec = contribution(activity="agent_running") + rec["active_work"] = {"task": "development_repair", "reason_ids": ["review-1"], + "requested_at": NOW, "revision": rec["revision"], + "dedupe_key": "repair", "deadline_at": NOW} + request = work.request_from_active(rec) + node = work.node(request, rec, control_repo_id="7", allowed_paths=["build.yml", "test.yml"], + context={"reason_evidence": [{"evidence_id": "review-1", + "kind": "human_relay", + "summary": "Add the test workflow."}]}) + self.assertTrue(node["payload"]["review_scope_extension"]) + self.assertEqual(node["payload"]["allowed_paths"], ["build.yml", "test.yml"]) + ordinary = work.node(request, rec, control_repo_id="7", allowed_paths=["build.yml"], + context={"reason_evidence": [{"evidence_id": "ci-1", "kind": "ci"}]}) + self.assertFalse(ordinary["payload"]["review_scope_extension"]) + def test_full_description_url_and_links_frozen_into_work(self): body = "### Additional context\n\nhttps://github.com/example/proj/pull/31488\n" + "user context\n" * 500 rec = contribution(phase="investigation", activity="idle") diff --git a/upstreaming/tests/test_fork_publish.py b/upstreaming/tests/test_fork_publish.py index fe3ebe6bdaf5..6a83086dd62b 100644 --- a/upstreaming/tests/test_fork_publish.py +++ b/upstreaming/tests/test_fork_publish.py @@ -45,6 +45,7 @@ def setUp(self): "allowed_operations": ["append", "rewrite"], "allowed_paths": [".github/workflows/*"], "reason_ids": ["ci-1"]} self.ops = [] + self.invocations = 0 def tearDown(self): fork_publish.URL_TEMPLATE, extra = self._saved @@ -71,12 +72,13 @@ def fork_head(self): return git(self.fork_bare, "rev-parse", "refs/heads/riscv64") def run_publish(self, proposal=None, mbox=None, pol=None, observe=None, scope=None): + self.invocations += 1 return fork_publish.publish( record=self.record, task=self.task, proposal=proposal or self.proposal(), mbox=self.mbox if mbox is None else mbox, token=None, observe_head=observe or self.fork_head, scope=scope or publisher.Scope(allowed_globs=[".github/workflows/*"]), policy=pol or policy(read_only=False), now=NOW, save_operation=self.ops.append, - workdir=self.root / f"pub-{len(self.ops)}-{id(proposal)}") + workdir=self.root / f"pub-{self.invocations}") class TestForkPublish(_ForkFixture, unittest.TestCase): def test_publishes_with_lease_and_confirms(self): @@ -89,6 +91,26 @@ def test_publishes_with_lease_and_confirms(self): expected = f"{fork_publish.APP_COMMIT_NAME};{fork_publish.APP_COMMIT_EMAIL}" self.assertEqual(identity, f"{expected};{expected}") + def test_authorized_review_repair_may_add_exact_changed_path_to_scope(self): + commit_files(self.agent, {"src/a.c": "int riscv64;\n"}, msg="BLD: follow review feedback") + self.mbox = git(self.agent, "format-patch", "--stdout", self.base).encode() + b"\n" + self.task["task"] = "development_repair" + self.task["review_scope_extension"] = True + proposal = self.proposal(reason_ids=["ci-1"], + changed_files=[".github/workflows/wheels.yml", "src/a.c"]) + out = self.run_publish(proposal=proposal) + self.assertEqual(out.status, "published", out.reason) + self.assertEqual(out.operation["proposed"]["changed_files"], + [".github/workflows/wheels.yml", "src/a.c"]) + + def test_non_review_task_cannot_expand_scope(self): + commit_files(self.agent, {"src/a.c": "int riscv64;\n"}, msg="BLD: unrelated scope") + self.mbox = git(self.agent, "format-patch", "--stdout", self.base).encode() + b"\n" + proposal = self.proposal(changed_files=[".github/workflows/wheels.yml", "src/a.c"]) + out = self.run_publish(proposal=proposal) + self.assertEqual((out.status, out.failure_class), ("rejected", "validation")) + self.assertIn("outside admitted scope", out.reason) + def test_read_only_validates_but_does_not_push(self): out = self.run_publish(pol=policy(read_only=True)) self.assertEqual(out.status, "rejected") @@ -97,8 +119,8 @@ def test_read_only_validates_but_does_not_push(self): def test_rejects_out_of_scope_and_lies(self): out = self.run_publish(scope=publisher.Scope(allowed_globs=["src/*"])) - self.assertIn("outside the approved patch surface", out.reason) - out = self.run_publish(self.proposal(changed_files=["src/a.c"])) + self.assertIn("outside admitted scope", out.reason) + out = self.run_publish(self.proposal(changed_files=[".github/workflows/other.yml"])) self.assertIn("proposal claims files", out.reason) out = self.run_publish(self.proposal(patch_digest="0" * 64)) self.assertIn("digest", out.reason) diff --git a/upstreaming/tests/test_observation.py b/upstreaming/tests/test_observation.py index 20ce15563412..5dde407feedc 100644 --- a/upstreaming/tests/test_observation.py +++ b/upstreaming/tests/test_observation.py @@ -8,7 +8,7 @@ from datetime import datetime, timedelta, timezone from pathlib import Path -from upstreaming import (capacity, ci_evidence, collect, commands, common, controller, recovery, +from upstreaming import (capacity, ci_evidence, collect, commands, controller, recovery, release, triggers) from upstreaming.tests.helpers import (NOW, OWNER, SHA_A, SHA_B, comment, contribution, policy) @@ -255,14 +255,6 @@ def test_only_new_authorized_current_head_review_feedback_is_returned(self): self.assertIsNone(collect.development_review_feedback(self.Api(), rec, [OWNER["id"]])) -class TestScopeNormalization(unittest.TestCase): - def test_workflow_files_share_a_bounded_repair_scope(self): - self.assertEqual(common.normalize_workflow_scope([ - ".github/workflows/wheels.yml", "README.rst", ".github/workflows/test.yml"]), - [".github/workflows/*", "README.rst"]) - self.assertEqual(common.normalize_workflow_scope(["src/port.c"]), ["src/port.c"]) - - class TestTriggers(unittest.TestCase): def test_semantics(self): doc = {"on": {"push": {"branches": ["main"], "paths": ["docs/**", "!docs/x/**"]}}} @@ -411,7 +403,7 @@ def test_investigation_outcome_auto_admits_development(self): self.assertEqual(final["dossier_evidence_id"], ev[0]["evidence_id"]) self.assertEqual((final["phase"], final["activity"], final["revision"]), ("provisioning", "waiting_capacity", 1)) self.assertEqual(final["admission_class"], "configuration_integration") - self.assertEqual(final["scope_paths"], [".github/workflows/*"]) + self.assertEqual(final["scope_paths"], [".github/workflows/*", "README.rst"]) self.assertIsNone(final["pending_human_action"]) self.assertIsNone(final["proposal_artifact"]) self.assertEqual(len(out.report["provision_requests"]), 1) diff --git a/upstreaming/tests/test_pipeline.py b/upstreaming/tests/test_pipeline.py index 7d1bd77cd6b3..13d1137b13f3 100644 --- a/upstreaming/tests/test_pipeline.py +++ b/upstreaming/tests/test_pipeline.py @@ -258,6 +258,13 @@ def test_success_after_retry_clears_pending(self): "operation": None, "artifact": None} self.assertIsNone(self.final(self.tick(rec, [ok]))["pending_publication"]) + def test_verified_review_paths_are_persisted_in_contribution_scope(self): + self.rec["scope_paths"] = ["build.yml"] + op = {"operation_id": "op-1", "proposed": {"changed_files": ["build.yml", "test.yml"]}} + updated, _ = reconcile.apply_publication( + self.rec, {"status": "published", "operation": op}, now=self.now.isoformat()) + self.assertEqual(updated["scope_paths"], ["build.yml", "test.yml"]) + class TestDispatchRecovery(unittest.TestCase): """A requested task whose dispatch never reached the queue (live run diff --git a/upstreaming/work.py b/upstreaming/work.py index 3cd0553f9a1a..aad3b8352a47 100644 --- a/upstreaming/work.py +++ b/upstreaming/work.py @@ -86,6 +86,8 @@ def payload(request: dict, record: dict, *, control_repo_id: str, allowed_paths: "upstream_facing": record.get("upstream_pr") is not None, "allowed_operations": ALLOWED_OPERATIONS[task], "allowed_paths": allowed_paths, + "review_scope_extension": task in ("development_repair", "upstream_revision") and any( + item.get("kind") == "human_relay" for item in context.get("reason_evidence") or []), "distributions": record.get("distributions") or [], "admission_class": record.get("admission_class"), "reason_ids": request.get("reason_ids") or [],