You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.ts — export 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.tsisFocusManifestPublicSafe (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)
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.ts—export type AiPolicyVerdict = { allowed: boolean; matchedPhrase: string | null; source: "CONTRIBUTING.md" | "AI-USAGE.md" | "none" }andexport 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 returnsallowed: false; no match returnsallowed: true, matchedPhrase: null.export function resolveAiPolicyVerdict(docs: { contributing: string | null; aiUsage: string | null }): AiPolicyVerdict— scansAI-USAGE.mdfirst (more specific), falls back toCONTRIBUTING.md, defaults to{ allowed: true, matchedPhrase: null, source: "none" }when both are absent.allowed: true; a document present but empty-string returnsallowed: true;AI-USAGE.mdtaking precedence over a conflictingCONTRIBUTING.mdwhen both are supplied; both docs absent (null,null) returns thesource: "none"default.References
src/signals/focus-manifest.tsisFocusManifestPublicSafe(line 300) — sibling pattern of a small explicit-phrase text scanner used defensively (public-safety scanning) as a style referencepackages/gittensory-engine/lib/ai-policy-map.ts(this issue creates it)