Skip to content

feat(miner-discovery): per-repo AI-policy map — parse CONTRIBUTING/AI-USAGE docs for AI-PR bans #2305

Description

@JSONbored

Before a miner spends any effort on a repo, it must check whether that repo bans AI-generated PRs. Implement a deterministic, best-effort text scanner over a repo's CONTRIBUTING.md / AI-USAGE.md-shaped documents (fetched as public metadata — raw file content via the GitHub contents API, never a clone) that returns a simple allow/deny verdict, so downstream discovery can hard-skip banned repos entirely. Conservative-by-construction: ambiguous or absent policy text defaults to "allowed" (never invent a ban), while an explicit ban phrase always wins.

Deliverables

  • packages/gittensory-engine/lib/ai-policy-map.tsexport type AiPolicyVerdict = { allowed: boolean; matchedPhrase: string | null; source: "CONTRIBUTING.md" | "AI-USAGE.md" | "none" } and export function scanAiPolicyText(content: string | null, source: AiPolicyVerdict["source"]): AiPolicyVerdict — a case-insensitive phrase scanner for a small, explicit ban-phrase list (e.g. /no ai[- ]generated (pull requests|prs|contributions)/i, /ai[- ]generated (prs?|contributions?) (are|will be) (banned|rejected|not accepted)/i, /do not (use|submit) ai[- ](written|generated) code/i) — matching returns allowed: false; no match returns allowed: true, matchedPhrase: null.
  • export function resolveAiPolicyVerdict(docs: { contributing: string | null; aiUsage: string | null }): AiPolicyVerdict — scans AI-USAGE.md first (more specific), falls back to CONTRIBUTING.md, defaults to { allowed: true, matchedPhrase: null, source: "none" } when both are absent.
  • Unit tests: each ban-phrase pattern individually matches on a realistic sentence fixture; a document with no ban language returns allowed: true; a document present but empty-string returns allowed: true; AI-USAGE.md taking precedence over a conflicting CONTRIBUTING.md when both are supplied; both docs absent (null, null) returns the source: "none" default.
  • A doc-comment explicitly stating the conservative bias: false-negatives (missing a real ban) are acceptable and expected to shrink over time as phrases are added; false-positives (banning a repo that doesn't actually ban AI) are the worse failure mode and phrases must stay literal/explicit, never a fuzzy heuristic.

References

  • src/signals/focus-manifest.ts isFocusManifestPublicSafe (line 300) — sibling pattern of a small explicit-phrase text scanner used defensively (public-safety scanning) as a style reference
  • CONTRIBUTING.md (repo root, 17804 bytes) — an example of the document shape being scanned (not itself scanned by this code — it's gittensory's own contributing doc, used only as a realistic test fixture)
  • new path: packages/gittensory-engine/lib/ai-policy-map.ts (this issue creates it)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:featureGittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.help wantedExtra attention is needed

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions