import type { RouteConfidence } from "../../src/core/domain-router.ts";

export type DomainRoutingCategory = "clear-match" | "borderline" | "adversarial" | "fallback";

export interface DomainRoutingCorpusEntry {
	readonly id: string;
	readonly task: string;
	readonly paths?: readonly string[];
	readonly tags?: readonly string[];
	readonly expectedDomain: string;
	readonly expectedConfidence?: RouteConfidence;
	readonly category: DomainRoutingCategory;
	readonly notes: string;
	readonly absentLeaderSignalPatterns?: readonly RegExp[];
}

export const DOMAIN_ROUTING_CORPUS: readonly DomainRoutingCorpusEntry[] = [
	{
		id: "fe-001",
		task: "build a responsive tailwind login form",
		paths: ["src/app/page.tsx"],
		expectedDomain: "frontend-ui",
		expectedConfidence: "confident",
		category: "clear-match",
		notes: "Tailwind plus page path is a clear frontend UI task.",
	},
	{
		id: "fe-002",
		task: "버튼 호버 애니메이션과 css 수정해줘",
		expectedDomain: "frontend-ui",
		category: "clear-match",
		notes: "Korean hybrid request with CSS and animation should stay frontend.",
	},
	{
		id: "fe-003",
		task: "fix the css bug in the react component",
		expectedDomain: "frontend-ui",
		expectedConfidence: "confident",
		category: "adversarial",
		notes: "Bug wording is a QA trap; CSS + React component intent is UI.",
	},
	{
		id: "fe-004",
		task: "컴포넌트 디자인 개선",
		expectedDomain: "frontend-ui",
		category: "clear-match",
		notes: "Common Korean component/design trigger should route to frontend.",
	},
	{
		id: "fe-005",
		task: "redesign the modal layout for accessibility",
		expectedDomain: "frontend-ui",
		expectedConfidence: "confident",
		category: "clear-match",
		notes: "Multiple UI signals with accessibility.",
	},

	{
		id: "be-001",
		task: "add a postgres migration for the users table",
		paths: ["migrations/0001.sql"],
		expectedDomain: "backend-api",
		expectedConfidence: "confident",
		category: "clear-match",
		notes: "Postgres migration is a clear backend task.",
	},
	{
		id: "be-002",
		task: "graphql resolver와 prisma orm 설정",
		expectedDomain: "backend-api",
		expectedConfidence: "confident",
		category: "clear-match",
		notes: "GraphQL plus ORM backend signals.",
	},
	{
		id: "be-003",
		task: "analyze the query performance",
		expectedDomain: "backend-api",
		category: "adversarial",
		notes: "Genuine query-performance signal; must not score backend from orm inside performance.",
		absentLeaderSignalPatterns: [/keyword:"orm"/],
	},
	{
		id: "be-004",
		task: "auth 미들웨어 추가",
		expectedDomain: "backend-api",
		category: "borderline",
		notes: "Auth middleware is backend even with mixed Korean wording.",
	},
	{
		id: "be-005",
		task: "add an api endpoint for session login",
		paths: ["src/server/routes/session.ts"],
		expectedDomain: "backend-api",
		expectedConfidence: "confident",
		category: "clear-match",
		notes: "API endpoint plus server path is backend.",
	},

	{
		id: "ds-001",
		task: "train a pytorch classifier, plot the dataset",
		paths: ["notebooks/model.ipynb"],
		expectedDomain: "data-science",
		expectedConfidence: "confident",
		category: "clear-match",
		notes: "Notebook, PyTorch, dataset, and plotting are clear data science signals.",
	},
	{
		id: "ds-002",
		task: "pandas dataframe으로 EDA하고 시각화",
		expectedDomain: "data-science",
		expectedConfidence: "confident",
		category: "clear-match",
		notes: "Pandas/dataframe/EDA hybrid request.",
	},
	{
		id: "ds-003",
		task: "vector search with embeddings",
		expectedDomain: "data-science",
		category: "clear-match",
		notes: "Embeddings/vector search are model/data retrieval signals, so data-science is preferred over ai-agent-ops.",
	},
	{
		id: "ds-004",
		task: "run statistical regression analysis on the dataset",
		expectedDomain: "data-science",
		expectedConfidence: "confident",
		category: "clear-match",
		notes: "Statistics, regression, analysis, dataset.",
	},
	{
		id: "ds-005",
		task: "model serving latency for inference",
		expectedDomain: "data-science",
		category: "borderline",
		notes: "No ml-infra domain exists yet; inference/model wording should remain in data-science.",
	},

	{
		id: "sec-001",
		task: "scan for xss, sql injection and secret leaks",
		expectedDomain: "security-audit",
		expectedConfidence: "confident",
		category: "clear-match",
		notes: "Security scan with XSS, injection, and leaks.",
	},
	{
		id: "sec-002",
		task: "CVE-2024-1234 취약점 분석하고 권한상승 점검",
		expectedDomain: "security-audit",
		expectedConfidence: "confident",
		category: "clear-match",
		notes: "CVE and Korean vulnerability wording.",
	},
	{
		id: "sec-003",
		task: "data leak in the logs",
		expectedDomain: "security-audit",
		category: "adversarial",
		notes: "Data is a data-science trap; leak intent is security.",
	},
	{
		id: "sec-004",
		task: "threat model the webhook authentication flow",
		expectedDomain: "security-audit",
		expectedConfidence: "confident",
		category: "clear-match",
		notes: "Threat modeling and auth flow are security audit signals.",
	},

	{
		id: "do-001",
		task: "deploy with docker to vercel",
		paths: ["Dockerfile"],
		expectedDomain: "devops-infra",
		expectedConfidence: "confident",
		category: "clear-match",
		notes: "Deploy, Docker, Vercel, Dockerfile.",
	},
	{
		id: "do-002",
		task: "kubernetes helm 차트와 github actions CI",
		expectedDomain: "devops-infra",
		expectedConfidence: "confident",
		category: "clear-match",
		notes: "Kubernetes, Helm, GitHub Actions, CI.",
	},
	{
		id: "do-003",
		task: "docker-compose the build pipeline",
		expectedDomain: "devops-infra",
		expectedConfidence: "confident",
		category: "adversarial",
		notes: "Compose wording is a mobile trap; Docker compose and pipeline are infra.",
	},
	{
		id: "do-004",
		task: "배포 스크립트 점검",
		expectedDomain: "devops-infra",
		category: "clear-match",
		notes: "Korean deploy trigger should route to devops.",
	},
	{
		id: "do-005",
		task: "release workflow for github actions",
		paths: [".github/workflows/release.yml"],
		expectedDomain: "devops-infra",
		expectedConfidence: "confident",
		category: "clear-match",
		notes: "Workflow path plus release/GitHub Actions.",
	},

	{
		id: "rs-001",
		task: "do a literature review on rlhf, cite arxiv sources",
		expectedDomain: "research",
		expectedConfidence: "confident",
		category: "clear-match",
		notes: "Literature review with citations and arXiv.",
	},
	{
		id: "rs-002",
		task: "경쟁사 competitor 조사하고 시장 market 비교 리포트",
		expectedDomain: "research",
		expectedConfidence: "confident",
		category: "clear-match",
		notes: "Hybrid competitor/market research.",
	},
	{
		id: "rs-003",
		task: "investigate why the build is slow",
		expectedDomain: "research",
		category: "adversarial",
		notes: "Build is a devops trap; investigate intent is read-only research.",
	},
	{
		id: "rs-004",
		task: "compare package alternatives with sources",
		expectedDomain: "research",
		category: "clear-match",
		notes: "Compare plus sources indicates research.",
	},

	{
		id: "mb-001",
		task: "refactor the navigation stack",
		paths: ["ios/App/Navigator.swift"],
		expectedDomain: "mobile",
		expectedConfidence: "confident",
		category: "clear-match",
		notes: "Swift path flips generic refactor toward mobile.",
	},
	{
		id: "mb-002",
		task: "jetpack compose 화면 전환 개선",
		expectedDomain: "mobile",
		expectedConfidence: "confident",
		category: "clear-match",
		notes: "Jetpack Compose should still route mobile after plain-English compose is constrained.",
	},
	{
		id: "mb-003",
		task: "compose multiplatform navigation state",
		expectedDomain: "mobile",
		category: "clear-match",
		notes: "Compose Multiplatform is a mobile/KMP signal.",
	},
	{
		id: "mb-004",
		task: "expo로 푸시알림 추가",
		expectedDomain: "mobile",
		category: "clear-match",
		notes: "Expo hybrid mobile request.",
	},

	{
		id: "dw-001",
		task: "write the readme and the changelog entry",
		expectedDomain: "docs-writing",
		expectedConfidence: "confident",
		category: "clear-match",
		notes: "Readme and changelog writing.",
	},
	{
		id: "dw-002",
		task: "API 문서와 튜토리얼 작성",
		expectedDomain: "docs-writing",
		category: "clear-match",
		notes: "Korean docs/tutorial should beat backend API.",
	},
	{
		id: "dw-003",
		task: "write a blog post about our api",
		expectedDomain: "docs-writing",
		category: "adversarial",
		notes: "API is a backend trap; blog/write intent is docs.",
	},
	{
		id: "dw-004",
		task: "발표 슬라이드 5장 만들어줘",
		expectedDomain: "docs-writing",
		category: "clear-match",
		notes: "Korean slides trigger should route to docs-writing.",
	},
	{
		id: "dw-005",
		task: "proofread the release notes",
		expectedDomain: "docs-writing",
		category: "clear-match",
		notes: "Proofreading/release notes are writing tasks.",
	},

	{
		id: "qa-001",
		task: "fix the failing playwright e2e tests",
		paths: ["tests/login.test.ts"],
		expectedDomain: "qa-testing",
		expectedConfidence: "confident",
		category: "clear-match",
		notes: "Playwright e2e tests plus test path.",
	},
	{
		id: "qa-002",
		task: "vitest 커버리지 올리고 flaky 테스트 잡아",
		expectedDomain: "qa-testing",
		expectedConfidence: "confident",
		category: "clear-match",
		notes: "Vitest, coverage, flaky, Korean test.",
	},
	{
		id: "qa-003",
		task: "write unit tests for the data model",
		expectedDomain: "qa-testing",
		category: "adversarial",
		notes: "Data/model are data-science/backend traps; unit tests intent must win.",
	},
	{
		id: "qa-004",
		task: "버그 수정",
		expectedDomain: "qa-testing",
		category: "clear-match",
		notes: "Common Korean bug-fix trigger should route to QA.",
	},
	{
		id: "qa-005",
		task: "add integration tests with fixtures",
		expectedDomain: "qa-testing",
		category: "clear-match",
		notes: "Integration tests plus fixtures.",
	},

	{
		id: "ai-001",
		task: "build an mcp server and eval the agent harness",
		expectedDomain: "ai-agent-ops",
		expectedConfidence: "confident",
		category: "clear-match",
		notes: "MCP, eval, agent, harness.",
	},
	{
		id: "ai-002",
		task: "서브에이전트 subagent 루프와 context engineering 설계",
		expectedDomain: "ai-agent-ops",
		expectedConfidence: "confident",
		category: "clear-match",
		notes: "Hybrid subagent/context-engineering signal.",
	},
	{
		id: "ai-003",
		task: "prompt the model",
		expectedDomain: "ai-agent-ops",
		category: "adversarial",
		notes: "Model is a data/backend trap; prompt intent is agent ops.",
	},
	{
		id: "ai-004",
		task: "훅 하나 추가해줘",
		expectedDomain: "ai-agent-ops",
		category: "borderline",
		notes: "Korean hook request should route to agent ops when hook is explicit.",
	},

	{
		id: "ge-001",
		task: "hello there",
		expectedDomain: "general",
		expectedConfidence: "fallback",
		category: "fallback",
		notes: "No domain signal.",
	},
	{
		id: "ge-002",
		task: "refactor this function",
		expectedDomain: "general",
		expectedConfidence: "fallback",
		category: "fallback",
		notes: "Generic engineering wording should remain below weak threshold.",
	},
	{
		id: "ge-003",
		task: "implement a helper function",
		expectedDomain: "general",
		expectedConfidence: "fallback",
		category: "fallback",
		notes: "Generic helper implementation.",
	},
	{
		id: "ge-004",
		task: "안녕하세요 오늘 날씨 어때",
		expectedDomain: "general",
		expectedConfidence: "fallback",
		category: "fallback",
		notes: "Korean small talk should not over-route.",
	},
	{
		id: "ge-005",
		task: "compose an email to the team",
		expectedDomain: "general",
		expectedConfidence: "fallback",
		category: "fallback",
		notes: "Plain-English email composition must not route to mobile Compose.",
	},
	{
		id: "ge-006",
		task: "translate this short sentence",
		expectedDomain: "general",
		expectedConfidence: "fallback",
		category: "fallback",
		notes: "No i18n-localization domain exists yet, so plain translation remains fallback.",
	},
	{
		id: "ge-007",
		task: "결제 구독 상태 알려줘",
		expectedDomain: "general",
		expectedConfidence: "fallback",
		category: "fallback",
		notes: "No payments-billing domain exists yet, so Korean billing-only request remains fallback.",
	},
	{
		id: "ge-008",
		task: "make it better",
		expectedDomain: "general",
		expectedConfidence: "fallback",
		category: "fallback",
		notes: "Underspecified request should stay general.",
	},
] as const;
