diff --git a/CHANGELOG.md b/CHANGELOG.md index 4843c00..ba3c124 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ ## Unreleased +- **Verified template-free native Issue route (PATCH, 2026-11-26):** Recognize a blank Issue only after pinned local/inherited configuration and legacy template checks plus GitHub GraphQL confirmation of an empty effective template list, enabled Issues and matching default HEAD. Preserve unknown/forbidden channel, original payload, history, PAUSE and exact consent gates. + - **Inherited native Issue forms (PATCH, 2026-11-26):** Resolve public owner/.github default templates only when no local directory/config exists, pin the effective source and identify Feature Request forms by declared name (including feature.yml). Preserve local precedence, unknown-channel, native-field, original-head and consent gates. - **Roadmap owner-facing publication candidate (2026-11-26):** Always report the concrete recommended outward Issue/comment/Discussion (or explicit no outreach), destination, proposed title and inline available body, native channel and readiness separately from internal case links. Blocked drafts remain unapproved local drafts with missing facts and unlock; persistence/history/native/consent gates unchanged. diff --git a/scripts/preflight_publication_destination.py b/scripts/preflight_publication_destination.py index 7f4deee..cffe58c 100644 --- a/scripts/preflight_publication_destination.py +++ b/scripts/preflight_publication_destination.py @@ -24,7 +24,7 @@ def is_feature_template(entry): return "feature" in name and "request" in name -def route_errors(target, original, kind, purpose, repo, templates=None, config=None, categories=None): +def route_errors(target, original, kind, purpose, repo, templates=None, config=None, categories=None, verified_blank_issue=False): """Pure fail-closed route predicate. Pass first-party GitHub snapshots, not guesses.""" errors = [] if not REPO.fullmatch(target) or not REPO.fullmatch(original): @@ -49,7 +49,9 @@ def route_errors(target, original, kind, purpose, repo, templates=None, config=N if repo.get("has_issues") is not True: errors.append("ISSUES_DISABLED") if kind == "original_issue": - if templates is None: + if verified_blank_issue is True and not templates and config is None: + pass # Verified effective absence, not an unknown response. + elif templates is None: errors.append("ISSUE_CHANNEL_EVIDENCE_UNVERIFIED") else: feature_template = any(is_feature_template(x) for x in templates) @@ -260,6 +262,34 @@ def classify_issue_templates(templates, source, ref): return classified, contents +def verify_blank_issue_route(target, original_pin, templates, config, source, ref): + """Require no local/inherited form or config and provider-confirmed effective absence.""" + if templates or config is not None: + return False + for repo, pin in sorted({(target, original_pin), (source, ref)}): + for path in (".github/ISSUE_TEMPLATE/config.yaml", ".github/ISSUE_TEMPLATE.md", + "ISSUE_TEMPLATE.md", "docs/ISSUE_TEMPLATE.md"): + if get_optional_file(repo, path, pin) is not None: + return False + owner, name = target.split("/", 1) + query = ("query($owner:String!,$name:String!){repository(owner:$owner,name:$name)" + "{nameWithOwner hasIssuesEnabled issueTemplates{name filename} " + "defaultBranchRef{target{oid}}}}") + call = subprocess.run( + ["gh", "api", "graphql", "-f", f"query={query}", + "-f", f"owner={owner}", "-f", f"name={name}"], + text=True, capture_output=True, check=False) + if call.returncode: + raise RuntimeError("EFFECTIVE_ISSUE_TEMPLATES_READ_FAILED") + result = json.loads(call.stdout) + repo = (result.get("data") or {}).get("repository") or {} + if result.get("errors") or repo.get("nameWithOwner") != target: + raise RuntimeError("EFFECTIVE_ISSUE_TEMPLATES_UNVERIFIED") + return (repo.get("hasIssuesEnabled") is True + and repo.get("issueTemplates") == [] + and ((repo.get("defaultBranchRef") or {}).get("target") or {}).get("oid") == original_pin) + + def get_categories(repo): owner, name = repo.split("/", 1) query = ("query($owner:String!,$name:String!){repository(owner:$owner,name:$name)" @@ -296,10 +326,13 @@ def main(): else: repo = gh_api("repos/" + args.target) templates = config = categories = None + verified_blank_issue = False if args.kind == "original_issue": original_pin = pinned_head(args.target, repo.get("default_branch")) templates, config, template_repo, ref = resolve_issue_templates( args.target, original_pin) + verified_blank_issue = verify_blank_issue_route( + args.target, original_pin, templates, config, template_repo, ref) templates, template_contents = classify_issue_templates(templates, template_repo, ref) proof["issue_template_source"] = { "repository": template_repo, "commit": ref, @@ -311,8 +344,20 @@ def main(): elif args.kind == "original_discussion": categories = get_categories(args.target) errors = route_errors(args.target, args.original, args.kind, args.purpose, - repo, templates, config, categories) - if args.kind == "original_issue" and not errors: + repo, templates, config, categories, verified_blank_issue) + if args.kind == "original_issue" and not errors and verified_blank_issue: + proof["native_blank_issue"] = { + "url": f"https://github.com/{args.target}/issues/new", + "effective_templates": [], "required_fields": [], + "required_checkboxes": [], "source_head": original_pin, + "provider_rule": "https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/creating-an-issue"} + if bool(args.title_file) != bool(args.body_file): + errors.append("TITLE_AND_BODY_REQUIRED_TOGETHER") + elif args.title_file and args.body_file: + from pathlib import Path + if not Path(args.title_file).read_text().strip() or not Path(args.body_file).read_text().strip(): + errors.append("BLANK_ISSUE_TITLE_OR_BODY_MISSING") + if args.kind == "original_issue" and not errors and not verified_blank_issue: form_names = [x.get("name") for x in templates or [] if is_feature_template(x)] if len(form_names) != 1: diff --git a/tests/test_publication_destination.py b/tests/test_publication_destination.py index 12a22e7..4d56000 100644 --- a/tests/test_publication_destination.py +++ b/tests/test_publication_destination.py @@ -201,6 +201,45 @@ def test_missing_config_and_template_blocks(self): repo(AG2), templates=None, config=None) self.assertIn("ISSUE_CHANNEL_EVIDENCE_UNVERIFIED", errs) + def test_verified_blank_route_requires_effective_absence(self): + self.assertEqual(route_errors(AG2, AG2, "original_issue", "feature_request", + repo(AG2), verified_blank_issue=True), []) + self.assertIn("ISSUES_DISABLED", route_errors( + AG2, AG2, "original_issue", "feature_request", repo(AG2, has_issues=False), + verified_blank_issue=True)) + self.assertIn("FEATURE_REQUEST_ROUTED_TO_DISCUSSIONS", route_errors( + CLINE, CLINE, "original_issue", "feature_request", repo(CLINE), [], + "blank_issues_enabled: false\nurl: https://github.com/cline/cline/discussions/categories/feature-requests", + verified_blank_issue=True)) + + def test_blank_verification_provider_and_pin(self): + from types import SimpleNamespace + import json + pin = "a"*40 + good = {"nameWithOwner": AG2, "hasIssuesEnabled": True, + "issueTemplates": [], "defaultBranchRef": {"target": {"oid": pin}}} + with patch.object(destination, "get_optional_file", return_value=None), \ + patch.object(destination.subprocess, "run") as run: + for changes, expected in (({}, True), ({"issueTemplates": None}, False), + ({"issueTemplates": [{"name": "Bug"}]}, False), + ({"hasIssuesEnabled": False}, False), + ({"defaultBranchRef": {"target": {"oid": "b"*40}}}, False)): + run.return_value = SimpleNamespace(returncode=0, stdout=json.dumps( + {"data": {"repository": {**good, **changes}}})) + self.assertEqual(destination.verify_blank_issue_route( + AG2, pin, None, None, AG2, pin), expected) + run.return_value = SimpleNamespace(returncode=1, stdout="") + with self.assertRaisesRegex(RuntimeError, "EFFECTIVE_ISSUE_TEMPLATES_READ_FAILED"): + destination.verify_blank_issue_route(AG2, pin, None, None, AG2, pin) + + def test_blank_verification_blocks_any_config_or_legacy_template(self): + pin = "a"*40 + self.assertFalse(destination.verify_blank_issue_route( + AG2, pin, None, "blank_issues_enabled: false", AG2, pin)) + with patch.object(destination, "get_optional_file", return_value="legacy"): + self.assertFalse(destination.verify_blank_issue_route( + AG2, pin, None, None, AG2, pin)) + def test_both_feature_issue_and_discussion_route_is_ambiguous(self): errs = route_errors(AG2, AG2, "original_issue", "feature_request", repo(AG2), [{"name": "feature_request.yml"}],