import { CONTRACT_PATHS, type ModeProfile, type ResearchMode } from "@autoscholar/schemas"; const P = CONTRACT_PATHS; const BASE_REQUIRED = [ P.instruction, P.manifest, P.plan, P.feasibility, P.sources, P.sourceMap, P.referencesBib, P.mainTex, P.manuscriptBib, P.mainPdf, P.abstract, P.metadata, P.review1, P.revisions, P.events, P.runSummary, P.checksums, ]; export const MODE_PROFILES: Record = { empirical: { mode: "empirical", requiredArtifacts: [ ...BASE_REQUIRED, P.dataReadme, P.dataManifest, P.codeReadme, P.metrics, P.robustness, P.experimentLog, ], requiredEvidence: ["real-data-manifest", "executed-analysis", "robustness", "reported-values-trace"], autoPublishAllowed: true, humanReviewRequired: false, description: "Data-driven analysis with documented data provenance, executed code and robustness checks.", }, computational: { mode: "computational", requiredArtifacts: [...BASE_REQUIRED, P.codeReadme, P.metrics, P.robustness, P.experimentLog], requiredEvidence: ["executed-benchmark", "baselines", "seeds", "reported-values-trace"], autoPublishAllowed: true, humanReviewRequired: false, description: "Algorithms, systems and AI research with executable benchmarks, baselines and seeds.", }, theoretical: { mode: "theoretical", requiredArtifacts: [...BASE_REQUIRED, P.robustness], requiredEvidence: ["formal-statements", "derivations-or-proofs", "counterexample-search"], autoPublishAllowed: true, humanReviewRequired: false, description: "Mathematical and model-based results with explicit assumptions, derivations and proof checking.", }, review: { mode: "review", requiredArtifacts: [...BASE_REQUIRED, P.dataManifest, P.robustness], requiredEvidence: ["search-protocol", "screening-records", "verified-references"], autoPublishAllowed: true, humanReviewRequired: false, description: "Systematic or narrative literature synthesis with a documented search and screening protocol.", }, experimental: { mode: "experimental", requiredArtifacts: [ ...BASE_REQUIRED, P.dataReadme, P.dataManifest, P.codeReadme, P.metrics, P.robustness, P.experimentLog, ], requiredEvidence: ["protocol", "observed-vs-synthetic", "uncertainty", "reported-values-trace"], autoPublishAllowed: false, humanReviewRequired: true, description: "Simulations or authorized experiments; requires human review before publication.", }, humanities: { mode: "humanities", requiredArtifacts: [...BASE_REQUIRED, P.dataManifest, P.robustness], requiredEvidence: ["primary-source-provenance", "interpretation-justification"], autoPublishAllowed: true, humanReviewRequired: false, description: "Qualitative, textual or interpretive inquiry grounded in primary sources with provenance.", }, }; export const QUALITY_POLICY_VERSION = "2026.10-1"; /** Disciplines with regulatory sensitivity: never auto-publish without human review. */ export const HUMAN_REVIEW_DISCIPLINES = new Set(["medicine", "biology", "law", "psychology"]); export function effectiveAutoPublish( mode: ResearchMode, discipline: string, requested: boolean, ): { allowed: boolean; reason?: string } { const prof = MODE_PROFILES[mode]; if (!prof.autoPublishAllowed) return { allowed: false, reason: `mode ${mode} requires human review` }; if (HUMAN_REVIEW_DISCIPLINES.has(discipline)) return { allowed: false, reason: `discipline ${discipline} requires human review` }; return { allowed: requested }; }