Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions SESSIONLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@
- Required investigator and worker dependency audits to use the RISE simple index plus `PIP_PREFER_BINARY=true` when public PyPI lacks compatible riscv64 build/test wheels, and updated both mirrored porting-skill paths with resolver-scope guidance.
- Added a stale-proof `/upstreaming restart` command for abandoned contributions that keeps the same tracking issue and append-only ledger while starting a fresh queued lifecycle generation after writer quiescence.
- Added `/upstreaming refresh` to re-investigate an existing development PR with current prompts, replace its verified dossier scope, and require a fresh worker pass carrying the full new dossier plus pending review and CI evidence.
- Separated explicit explanation-only PR comments from change feedback so they are audited without revision bumps, `fix_needed` transitions, repair evidence, or misleading repair ledger text; repeated-pause rejection feedback now confirms the pause remains effective instead of repeating the submitted syntax.
5 changes: 5 additions & 0 deletions upstreaming/INTEGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ 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.
Explanation-only comments are classified separately as `human_inquiry` when
an explicit no-change instruction is present, or when they clearly request an
explanation without a repair instruction. They are marked processed and retained
for audit, but do not bump the revision, set `fix_needed`, enter pending repair
evidence, invalidate CI or handoff state, or claim that repair was requested.

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
Expand Down
49 changes: 42 additions & 7 deletions upstreaming/collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,34 @@ def tracking_issues(api: Api, contributions: Iterable[dict], intake_issues: list
return issues


_EXPLANATION_WORDS = re.compile(
r"(?:^|\b)(?:why|what happened|how did|explain|explanation|diagnose|diagnosis)(?:\b|$)", re.IGNORECASE)
_REPAIR_WORDS = re.compile(
r"(?:^|\b)(?:fix|update|add|remove|revert|disable|enable|implement|rename|delete|replace|set|use)(?:\b|$)",
re.IGNORECASE)
_NO_CHANGE = re.compile(
r"(?:do not|don't|dont|please do not|please don't)\s+(?:make\s+(?:any\s+)?)?(?:change|changes|modify|edit|push|commit|fix)\b|"
r"\bwithout\s+(?:changing|modifying|editing|pushing|committing|fixing)\b|"
r"\bno\s+(?:code\s+)?changes?\b",
re.IGNORECASE)


def review_comment_intent(body: str) -> str:
"""Conservatively distinguish an explanation request from repair feedback.

An explicit no-change instruction is authoritative. Otherwise only a clear
explanatory question with no repair verb is treated as inquiry-only.
"""
text = " ".join(body.split())
if _NO_CHANGE.search(text):
return "inquiry"
if _EXPLANATION_WORDS.search(text) and not _REPAIR_WORDS.search(text):
return "inquiry"
return "repair"


def development_review_feedback(api: Api, record: dict, authority: Iterable[int]) -> dict | None:
"""Return new authorized review feedback bound to the current fork head."""
"""Return new authorized review feedback or inquiries bound to the current fork head."""
fork = record.get("fork") or {}
number = fork.get("pr_number")
head = fork.get("head_sha")
Expand Down Expand Up @@ -191,7 +217,7 @@ def development_review_feedback(api: Api, record: dict, authority: Iterable[int]
"review_id": comment.get("pull_request_review_id"),
"reviewer": (comment.get("user") or {}).get("login"),
"path": comment.get("path"), "line": comment.get("line") or comment.get("original_line"),
"commit_id": head})
"commit_id": head, "intent": review_comment_intent(body)})
conversation_items = []
for comment in conversation:
body = (comment.get("body") or "").strip()
Expand All @@ -203,14 +229,23 @@ def development_review_feedback(api: Api, record: dict, authority: Iterable[int]
conversation_items.append({"id": comment["id"], "body": body[:8000],
"url": comment.get("html_url"),
"reviewer": (comment.get("user") or {}).get("login"),
"created_at": created, "commit_id": head})
"created_at": created, "commit_id": head,
"intent": review_comment_intent(body)})
if not review_items and not comment_items and not conversation_items:
return None
return {"reviews": review_items, "comments": comment_items,
"conversation_comments": conversation_items,
inquiry_comments = [item for item in comment_items if item["intent"] == "inquiry"]
inquiry_conversation = [item for item in conversation_items if item["intent"] == "inquiry"]
repair_comments = [item for item in comment_items if item["intent"] == "repair"]
repair_conversation = [item for item in conversation_items if item["intent"] == "repair"]
return {"reviews": review_items, "comments": repair_comments,
"conversation_comments": repair_conversation,
"review_ids": [item["id"] for item in review_items],
"comment_ids": [item["id"] for item in comment_items],
"conversation_comment_ids": [item["id"] for item in conversation_items]}
"comment_ids": [item["id"] for item in repair_comments],
"conversation_comment_ids": [item["id"] for item in repair_conversation],
"inquiry_comments": inquiry_comments,
"inquiry_conversation_comments": inquiry_conversation,
"inquiry_comment_ids": [item["id"] for item in inquiry_comments],
"inquiry_conversation_comment_ids": [item["id"] for item in inquiry_conversation]}


def upstream_snapshots(api: Api, contributions: Iterable[dict], issues: list[dict], policy: dict) -> dict[str, dict]:
Expand Down
13 changes: 12 additions & 1 deletion upstreaming/command_feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,18 @@ def render(receipt: dict, original: dict) -> str:
quoted = "\n".join("> " + line for line in body.splitlines())
reason = (receipt.get("reason") or receipt.get("result") or "command rejected").strip()
text = f"@{login}, this command was rejected:\n\n{quoted}\n\n**Reason:** {reason}"
template = TEMPLATES.get(_verb(body, receipt))
verb = _verb(body, receipt)
if reason == "already paused":
revision = receipt.get("revision")
suffix = f" revision={revision}" if revision is not None else " revision=N"
text += ("\n\n**No action is needed:** the contribution remains paused. "
"To continue it, use:\n```text\n"
f'/upstreaming resume{suffix} reason="..."\n```')
return text + f"\n\n<!-- upstreaming-command-feedback:{receipt['comment_id']} -->"
if reason == "not paused" and verb == "resume":
text += "\n\n**No action is needed:** the contribution is already active."
return text + f"\n\n<!-- upstreaming-command-feedback:{receipt['comment_id']} -->"
template = TEMPLATES.get(verb)
if template:
revision = receipt.get("revision")
if revision is None:
Expand Down
86 changes: 59 additions & 27 deletions upstreaming/observe_ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,34 +91,66 @@ def observe(api: collect.Api, *, contributions: dict[str, dict], operations: dic
feedback = collect.development_review_feedback(
api, cur, policy["command_authority"]["actor_ids"])
if feedback:
inquiry_ids = (feedback["inquiry_comment_ids"]
+ feedback["inquiry_conversation_comment_ids"])
if inquiry_ids:
inquiry_items = (feedback["inquiry_comments"]
+ feedback["inquiry_conversation_comments"])
inquiry_id = safe_id(
f"inquiry-{cur['fork']['repository_id']}-{cur['fork']['pr_number']}-{max(inquiry_ids)}")
inquiry_data = {"comments": feedback["inquiry_comments"],
"conversation_comments": feedback["inquiry_conversation_comments"]}
inquiry_ev = {"schema_version": 1, "evidence_id": inquiry_id,
"contribution_id": cid, "kind": "human_inquiry",
"policy_version": policy["policy_version"], "collected_at": now,
"summary": "\n\n".join(item["body"] for item in inquiry_items)[:8000],
"limitations": ["Explanation-only; no repair or mutation requested."],
"data": inquiry_data, "digests": {"head": head["head"]}}
schemas.validate("evidence", inquiry_ev)
before_inquiry = cur
cur = dict(cur,
processed_review_comment_ids=(
(cur.get("processed_review_comment_ids") or [])
+ feedback["inquiry_comment_ids"])[-512:],
processed_pr_conversation_comment_ids=(
(cur.get("processed_pr_conversation_comment_ids") or [])
+ feedback["inquiry_conversation_comment_ids"])[-512:],
updated_at=now)
schemas.validate("contribution", cur)
obs.staged.extend([("evidence", inquiry_ev), ("contributions", cur),
("events", lifecycle._event(
before_inquiry, cur, "development_review_inquiry",
"observation", inquiry_id, now, False))])
entry["review_inquiry"] = inquiry_id
ids = feedback["review_ids"] + feedback["comment_ids"] + feedback["conversation_comment_ids"]
eid = safe_id(f"review-{cur['fork']['repository_id']}-{cur['fork']['pr_number']}-{max(ids)}")
summaries = [item["body"] for item in
feedback["reviews"] + feedback["comments"] + feedback["conversation_comments"]]
ev = {"schema_version": 1, "evidence_id": eid, "contribution_id": cid,
"kind": "human_relay", "policy_version": policy["policy_version"],
"collected_at": now, "summary": "\n\n".join(summaries)[:8000],
"limitations": [], "data": feedback, "digests": {"head": head["head"]}}
schemas.validate("evidence", ev)
before = cur
cur = dict(cur, revision=cur["revision"] + 1, phase="development", activity="fix_needed",
active_work=None, active_operation_id=None, clean_head_sha=None,
handoff_request=None, handoff_approval=None, pending_human_action=None,
last_ci_evidence_id=eid,
processed_review_ids=((cur.get("processed_review_ids") or []) + feedback["review_ids"])[-256:],
processed_review_comment_ids=((cur.get("processed_review_comment_ids") or [])
+ feedback["comment_ids"])[-512:],
processed_pr_conversation_comment_ids=(
(cur.get("processed_pr_conversation_comment_ids") or [])
+ 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",
"observation", eid, now, True))])
entry["review_feedback"] = eid
if ids:
eid = safe_id(f"review-{cur['fork']['repository_id']}-{cur['fork']['pr_number']}-{max(ids)}")
summaries = [item["body"] for item in
feedback["reviews"] + feedback["comments"] + feedback["conversation_comments"]]
ev = {"schema_version": 1, "evidence_id": eid, "contribution_id": cid,
"kind": "human_relay", "policy_version": policy["policy_version"],
"collected_at": now, "summary": "\n\n".join(summaries)[:8000],
"limitations": [], "data": feedback, "digests": {"head": head["head"]}}
schemas.validate("evidence", ev)
before = cur
cur = dict(cur, revision=cur["revision"] + 1, phase="development", activity="fix_needed",
active_work=None, active_operation_id=None, clean_head_sha=None,
handoff_request=None, handoff_approval=None, pending_human_action=None,
last_ci_evidence_id=eid,
processed_review_ids=((cur.get("processed_review_ids") or []) + feedback["review_ids"])[-256:],
processed_review_comment_ids=((cur.get("processed_review_comment_ids") or [])
+ feedback["comment_ids"])[-512:],
processed_pr_conversation_comment_ids=(
(cur.get("processed_pr_conversation_comment_ids") or [])
+ 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",
"observation", eid, now, True))])
entry["review_feedback"] = eid
obs.report.append(entry)
continue
# A requested repair must reach the controller before another CI poll
Expand Down
1 change: 1 addition & 0 deletions upstreaming/schemas/evidence.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"benchmark",
"merge",
"human_relay",
"human_inquiry",
"resolution"
]
},
Expand Down
3 changes: 2 additions & 1 deletion upstreaming/status_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class LedgerError(ValueError):
"dossier_parked": "Verified the investigation dossier and parked the contribution because no bounded patch is actionable.",
"fork_provisioned": "Provisioned and verified the contribution fork and exact `riscv64` base.",
"development_pr_created": "Created and verified the same-fork development PR.",
"development_review_feedback": "Recorded authorized development-PR review feedback and requested repair.",
"development_review_feedback": "Recorded authorized development-PR change feedback and requested repair.",
"development_review_inquiry": "Recorded an authorized explanation-only development-PR comment. No repair was requested; lifecycle state is unchanged.",
"handoff_ready": "Accepted clean-head development CI and reached human upstream handoff.",
}

Expand Down
10 changes: 10 additions & 0 deletions upstreaming/tests/test_command_feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ def test_rejected_restart_has_actionable_template(self):
body = command_feedback.render(receipt, original)
self.assertIn('/upstreaming restart revision=7 reason="..."', body)

def test_repeated_pause_explains_that_pause_remains_effective(self):
receipt = {"comment_id": 42, "actor": {"login": "luhenry"}, "verb": "pause",
"reason": "already paused", "revision": 8}
original = {"body": '/upstreaming pause revision=8 reason="saving tokens"',
"user": {"login": "luhenry"}}
body = command_feedback.render(receipt, original)
self.assertIn("the contribution remains paused", body)
self.assertIn('/upstreaming resume revision=8 reason="..."', body)
self.assertNotIn("**Expected form:**", body)

def test_rejected_command_is_quoted_pings_author_and_shows_expected_form(self):
receipt = {"schema_version": 1, "command_id": "comment-42", "command_version": 1,
"comment_id": 42, "issue_number": 1138, "actor": {"id": 660779, "login": "luhenry"},
Expand Down
Loading