From 4d9fc905cd4fb97021e44919c7ef51865a49d6c5 Mon Sep 17 00:00:00 2001 From: EMRG Evolution Date: Thu, 20 Aug 2026 21:35:37 +0800 Subject: [PATCH 1/4] =?UTF-8?q?emrg:=20open-source=20prompt=20PR-issue=20l?= =?UTF-8?q?inking=20guard=20=E2=80=94=20verify=20linkedIssues,=20bot=20blo?= =?UTF-8?q?ck=20is=20hard=20(rant=202026-08-20T21:27:30)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- emrg/server/open_source_prompt.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/emrg/server/open_source_prompt.md b/emrg/server/open_source_prompt.md index f120d9a..e1a247f 100644 --- a/emrg/server/open_source_prompt.md +++ b/emrg/server/open_source_prompt.md @@ -381,6 +381,11 @@ Closes # - [ ] New tests added" ``` +> ⚠️ **PR-issue linking (rant 2026-08-20T21:27:30 — bot `needs:issue` hard-block, PR #43460/#43282 blocked 2 days)**: +> 1. **Verify the issue is actually linked, not just mentioned in the body.** A `Closes #` line in the PR body does NOT guarantee GitHub's linked-issue field (GraphQL `closingIssuesReferences`) is populated — some repos (e.g. anomalyco/opencode's pr-standards bot) gate on the linked-issue field and hard-block your PR with `needs:issue` even when the body says `Closes`. After creating the PR, verify with `gh pr view --json linkedIssues` (or GraphQL `closingIssuesReferences`); if it is empty, attempt association (`gh pr edit` / GraphQL `addLinkedIssues` / REST `POST /pulls/{n}/issues`) — if association still fails, record it in the state file and ask in the PR thread instead of assuming it worked. +> 2. **A bot `needs:issue` / block review comment is a HARD block, not an informational note.** Treat any bot review comment that blocks your PR as blocking until resolved — never dismiss it as "only an informational bot note". Misjudging it wasted 6 reflection rounds before the mistake was caught. +> 3. **Resolve bot blocks the same round you see them.** Do not defer a block to the next round (here a fix discovered 08-18 stayed unfixed until 08-20, missing the fix window); handle it until the block clears or the state file records an explicit blocker. + > ⚠️ **Publishing spec (rant 2026-08-20T14:10:28 — comment double-encoding bug)**: > 1. **Always pass RAW text as the body of any comment / discussion / issue / PR** — write the body to a file with a heredoc and submit via `--field body=@file` (or `$(cat file)` / inline text). **NEVER** use patterns like `python3 -c "import json; print(json.dumps(...))"` that JSON-serialize the body before submitting — GitHub renders the escaped literal as-is (中文→`\uXXXX`, newlines→literal `\n`, quotes wrapped), producing garbled text. > 2. **Always read back and verify the posted body**: after posting, fetch the comment and check that the first character is NOT `"` and the text contains no `\uXXXX` residuals. If garbled, fix immediately with `updateDiscussionComment` (or the equivalent edit mutation) using the decoded original. From 43c408d6a5be8811354307681967af4d8073ec39 Mon Sep 17 00:00:00 2001 From: EMRG Evolution Date: Thu, 20 Aug 2026 21:43:38 +0800 Subject: [PATCH 2/4] =?UTF-8?q?emrg:=20correct=20open-source=20PR-issue=20?= =?UTF-8?q?guard=20=E2=80=94=20non-default=20base=20branch=20nuance=20+=20?= =?UTF-8?q?working=20GraphQL=20commands=20(pm25coder=20+=20rant=20root-cau?= =?UTF-8?q?se=20fix)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- emrg/server/open_source_prompt.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/emrg/server/open_source_prompt.md b/emrg/server/open_source_prompt.md index e1a247f..4bdc7c3 100644 --- a/emrg/server/open_source_prompt.md +++ b/emrg/server/open_source_prompt.md @@ -381,10 +381,10 @@ Closes # - [ ] New tests added" ``` -> ⚠️ **PR-issue linking (rant 2026-08-20T21:27:30 — bot `needs:issue` hard-block, PR #43460/#43282 blocked 2 days)**: -> 1. **Verify the issue is actually linked, not just mentioned in the body.** A `Closes #` line in the PR body does NOT guarantee GitHub's linked-issue field (GraphQL `closingIssuesReferences`) is populated — some repos (e.g. anomalyco/opencode's pr-standards bot) gate on the linked-issue field and hard-block your PR with `needs:issue` even when the body says `Closes`. After creating the PR, verify with `gh pr view --json linkedIssues` (or GraphQL `closingIssuesReferences`); if it is empty, attempt association (`gh pr edit` / GraphQL `addLinkedIssues` / REST `POST /pulls/{n}/issues`) — if association still fails, record it in the state file and ask in the PR thread instead of assuming it worked. -> 2. **A bot `needs:issue` / block review comment is a HARD block, not an informational note.** Treat any bot review comment that blocks your PR as blocking until resolved — never dismiss it as "only an informational bot note". Misjudging it wasted 6 reflection rounds before the mistake was caught. -> 3. **Resolve bot blocks the same round you see them.** Do not defer a block to the next round (here a fix discovered 08-18 stayed unfixed until 08-20, missing the fix window); handle it until the block clears or the state file records an explicit blocker. +> ⚠️ **PR-issue linking (rant 2026-08-20T21:27:30 — bot `needs:issue` on PR #43460/#43282; root cause: non-default base branch)**: +> 1. **Check the PR base branch FIRST.** GitHub only resolves closing keywords (`Closes #N`) for PRs opened against the **default branch** (docs.github.com "Linking a pull request to an issue"). If your PR's base is NOT the default branch (e.g. anomalyco/opencode's `v2`), the linked-issue field stays empty no matter what, the bot's `needs:issue` check will NEVER pass, and that is NOT a blocker — the project merges fix PRs on such branches with linked=0 (v2 fix PRs #43590/#43618/#43625 all merged). Record the non-default base in the state file and ignore the check. +> 2. **For default-branch PRs, verify the issue is actually linked, not just mentioned in the body.** Verify via GraphQL `closingIssuesReferences` (`gh api graphql -f query='{ repository(owner:"{{ owner }}", name:"{{ repo }}") { pullRequest(number:N) { closingIssuesReferences(first:5) { nodes { number } } } }'`) — `gh pr view --json linkedIssues` FAILS on gh ≤ 2.58 (unknown field). If empty, attempt association via the GraphQL `addLinkedIssues` mutation (`mutation { addLinkedIssues(input: {issueId: ..., linkedPullRequestId: ..., relationship: CLOSES}) }`) — REST `POST /pulls/{n}/issues` is 404 and `gh pr edit` does not manage linked issues. If association still fails, record it in the state file and ask in the PR thread instead of assuming it worked. +> 3. **For default-branch PRs, a bot `needs:issue` / block review comment is a HARD block** — resolve it the same round you see it, never dismiss it as "only an informational bot note" (misjudging it wasted 6 reflection rounds), and do not defer to the next round (a fix discovered 08-18 stayed unfixed until 08-20, missing the fix window). Handle it until the block clears or the state file records an explicit blocker. > ⚠️ **Publishing spec (rant 2026-08-20T14:10:28 — comment double-encoding bug)**: > 1. **Always pass RAW text as the body of any comment / discussion / issue / PR** — write the body to a file with a heredoc and submit via `--field body=@file` (or `$(cat file)` / inline text). **NEVER** use patterns like `python3 -c "import json; print(json.dumps(...))"` that JSON-serialize the body before submitting — GitHub renders the escaped literal as-is (中文→`\uXXXX`, newlines→literal `\n`, quotes wrapped), producing garbled text. From e3bf1ed8b72a9c4f82adc71169e240008b2cbe30 Mon Sep 17 00:00:00 2001 From: EMRG Evolution Date: Thu, 20 Aug 2026 22:01:20 +0800 Subject: [PATCH 3/4] =?UTF-8?q?emrg:=20open-source=20prompt=20PR=20submiss?= =?UTF-8?q?ion=20rules=20=E2=80=94=20default=20branch=20base=20+=20act=20o?= =?UTF-8?q?n=20feedback,=20Jinja2-safe=20placeholders=20(rant=202026-08-20?= =?UTF-8?q?T21:53:36)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- emrg/server/open_source_prompt.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/emrg/server/open_source_prompt.md b/emrg/server/open_source_prompt.md index 4bdc7c3..fb6abbd 100644 --- a/emrg/server/open_source_prompt.md +++ b/emrg/server/open_source_prompt.md @@ -381,11 +381,10 @@ Closes # - [ ] New tests added" ``` -> ⚠️ **PR-issue linking (rant 2026-08-20T21:27:30 — bot `needs:issue` on PR #43460/#43282; root cause: non-default base branch)**: -> 1. **Check the PR base branch FIRST.** GitHub only resolves closing keywords (`Closes #N`) for PRs opened against the **default branch** (docs.github.com "Linking a pull request to an issue"). If your PR's base is NOT the default branch (e.g. anomalyco/opencode's `v2`), the linked-issue field stays empty no matter what, the bot's `needs:issue` check will NEVER pass, and that is NOT a blocker — the project merges fix PRs on such branches with linked=0 (v2 fix PRs #43590/#43618/#43625 all merged). Record the non-default base in the state file and ignore the check. -> 2. **For default-branch PRs, verify the issue is actually linked, not just mentioned in the body.** Verify via GraphQL `closingIssuesReferences` (`gh api graphql -f query='{ repository(owner:"{{ owner }}", name:"{{ repo }}") { pullRequest(number:N) { closingIssuesReferences(first:5) { nodes { number } } } }'`) — `gh pr view --json linkedIssues` FAILS on gh ≤ 2.58 (unknown field). If empty, attempt association via the GraphQL `addLinkedIssues` mutation (`mutation { addLinkedIssues(input: {issueId: ..., linkedPullRequestId: ..., relationship: CLOSES}) }`) — REST `POST /pulls/{n}/issues` is 404 and `gh pr edit` does not manage linked issues. If association still fails, record it in the state file and ask in the PR thread instead of assuming it worked. -> 3. **For default-branch PRs, a bot `needs:issue` / block review comment is a HARD block** — resolve it the same round you see it, never dismiss it as "only an informational bot note" (misjudging it wasted 6 reflection rounds), and do not defer to the next round (a fix discovered 08-18 stayed unfixed until 08-20, missing the fix window). Handle it until the block clears or the state file records an explicit blocker. - +> ⚠️ **PR submission rules (rant 2026-08-20T21:53:36 — supersedes earlier PR-issue linking notes)**: +> 1. **Base the PR on the DEFAULT branch.** Before opening a PR, check the target repo's default branch (`gh repo view --json defaultBranchRef`) and open the PR against it. GitHub only resolves closing keywords in the body/commit message into the linked-issue field when the PR base is the default branch; for any other base the linked field stays empty and bot checks like `needs:issue` never pass. If the repo explicitly requires a non-default base (e.g. per CONTRIBUTING), record in the state file that the check fails by design and is ignorable — do not keep retrying. +> 2. **Act on PR feedback the same round.** After creating the PR and in every reflection round, check bot/maintainer comments (`gh api repos///issues//comments`). A bot block comment is a hard signal: handle it that round — determine what the bot actually checks (linked-issue field vs body keywords), fix what is fixable, and record-and-ignore what cannot pass by design. Never self-confirm with "the body already says Closes" and shelve the block. +> 3. **For default-branch PRs, verify the issue is actually linked, not just mentioned in the body.** This prompt is Jinja2-rendered — use plain placeholders ``/``/`` (NOT `{{ }}` delimiters, which would be silently erased). Verify via GraphQL `closingIssuesReferences`: `gh api graphql -f query='{ repository(owner: "", name: "") { pullRequest(number: ) { closingIssuesReferences(first: 5) { nodes { number } } } } }'` — `gh pr view --json linkedIssues` FAILS on gh ≤ 2.58 (unknown field). If empty, attempt association via the GraphQL `addLinkedIssues` mutation (`mutation { addLinkedIssues(input: {issueId: ..., linkedPullRequestId: ..., relationship: CLOSES}) }`) — REST `POST /pulls//issues` is 404 and `gh pr edit` does not manage linked issues. If association still fails, record it in the state file and ask in the PR thread instead of assuming it worked. > ⚠️ **Publishing spec (rant 2026-08-20T14:10:28 — comment double-encoding bug)**: > 1. **Always pass RAW text as the body of any comment / discussion / issue / PR** — write the body to a file with a heredoc and submit via `--field body=@file` (or `$(cat file)` / inline text). **NEVER** use patterns like `python3 -c "import json; print(json.dumps(...))"` that JSON-serialize the body before submitting — GitHub renders the escaped literal as-is (中文→`\uXXXX`, newlines→literal `\n`, quotes wrapped), producing garbled text. > 2. **Always read back and verify the posted body**: after posting, fetch the comment and check that the first character is NOT `"` and the text contains no `\uXXXX` residuals. If garbled, fix immediately with `updateDiscussionComment` (or the equivalent edit mutation) using the decoded original. From e323d0b2fc486bc8fe15974b386433f563608525 Mon Sep 17 00:00:00 2001 From: EMRG Evolution Date: Thu, 20 Aug 2026 22:03:30 +0800 Subject: [PATCH 4/4] =?UTF-8?q?emrg:=20fix=20Jinja2=20parse=20=E2=80=94=20?= =?UTF-8?q?avoid=20literal=20double-brace=20in=20prompt=20guard=20text?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- emrg/server/open_source_prompt.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emrg/server/open_source_prompt.md b/emrg/server/open_source_prompt.md index fb6abbd..e7a5d50 100644 --- a/emrg/server/open_source_prompt.md +++ b/emrg/server/open_source_prompt.md @@ -384,7 +384,7 @@ Closes # > ⚠️ **PR submission rules (rant 2026-08-20T21:53:36 — supersedes earlier PR-issue linking notes)**: > 1. **Base the PR on the DEFAULT branch.** Before opening a PR, check the target repo's default branch (`gh repo view --json defaultBranchRef`) and open the PR against it. GitHub only resolves closing keywords in the body/commit message into the linked-issue field when the PR base is the default branch; for any other base the linked field stays empty and bot checks like `needs:issue` never pass. If the repo explicitly requires a non-default base (e.g. per CONTRIBUTING), record in the state file that the check fails by design and is ignorable — do not keep retrying. > 2. **Act on PR feedback the same round.** After creating the PR and in every reflection round, check bot/maintainer comments (`gh api repos///issues//comments`). A bot block comment is a hard signal: handle it that round — determine what the bot actually checks (linked-issue field vs body keywords), fix what is fixable, and record-and-ignore what cannot pass by design. Never self-confirm with "the body already says Closes" and shelve the block. -> 3. **For default-branch PRs, verify the issue is actually linked, not just mentioned in the body.** This prompt is Jinja2-rendered — use plain placeholders ``/``/`` (NOT `{{ }}` delimiters, which would be silently erased). Verify via GraphQL `closingIssuesReferences`: `gh api graphql -f query='{ repository(owner: "", name: "") { pullRequest(number: ) { closingIssuesReferences(first: 5) { nodes { number } } } } }'` — `gh pr view --json linkedIssues` FAILS on gh ≤ 2.58 (unknown field). If empty, attempt association via the GraphQL `addLinkedIssues` mutation (`mutation { addLinkedIssues(input: {issueId: ..., linkedPullRequestId: ..., relationship: CLOSES}) }`) — REST `POST /pulls//issues` is 404 and `gh pr edit` does not manage linked issues. If association still fails, record it in the state file and ask in the PR thread instead of assuming it worked. +> 3. **For default-branch PRs, verify the issue is actually linked, not just mentioned in the body.** This prompt is Jinja2-rendered — use plain placeholders ``/``/`` (NOT Jinja2 double-brace delimiters, which would be silently erased). Verify via GraphQL `closingIssuesReferences`: `gh api graphql -f query='{ repository(owner: "", name: "") { pullRequest(number: ) { closingIssuesReferences(first: 5) { nodes { number } } } } }'` — `gh pr view --json linkedIssues` FAILS on gh ≤ 2.58 (unknown field). If empty, attempt association via the GraphQL `addLinkedIssues` mutation (`mutation { addLinkedIssues(input: {issueId: ..., linkedPullRequestId: ..., relationship: CLOSES}) }`) — REST `POST /pulls//issues` is 404 and `gh pr edit` does not manage linked issues. If association still fails, record it in the state file and ask in the PR thread instead of assuming it worked. > ⚠️ **Publishing spec (rant 2026-08-20T14:10:28 — comment double-encoding bug)**: > 1. **Always pass RAW text as the body of any comment / discussion / issue / PR** — write the body to a file with a heredoc and submit via `--field body=@file` (or `$(cat file)` / inline text). **NEVER** use patterns like `python3 -c "import json; print(json.dumps(...))"` that JSON-serialize the body before submitting — GitHub renders the escaped literal as-is (中文→`\uXXXX`, newlines→literal `\n`, quotes wrapped), producing garbled text. > 2. **Always read back and verify the posted body**: after posting, fetch the comment and check that the first character is NOT `"` and the text contains no `\uXXXX` residuals. If garbled, fix immediately with `updateDiscussionComment` (or the equivalent edit mutation) using the decoded original.