2sagaco48 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/diagnostics.mjs +141 -0
- package/dist/compute.worker-j5ahIpF-.js +1 -0
- package/dist/graph.worker-DG6iGCB9.js +1 -0
- package/dist/index.html +2314 -0
- package/flatten-guide.md +248 -0
- package/index.html +12 -0
- package/package.json +38 -0
- package/src/App.orig.tsx +204 -0
- package/src/App.orig1.tsx +27 -0
- package/src/App.orig2.tsx +25 -0
- package/src/App.tsx +3 -0
- package/src/BaseApp.tsx +18 -0
- package/src/INTEGRATION_LEDGER.md +22 -0
- package/src/PERSIST_CANARY.orig.txt +1 -0
- package/src/PERSIST_CANARY.txt +1 -0
- package/src/REGRESSION_LEDGER.md +651 -0
- package/src/TEMPLATE_PIPELINE_AUDIT.md +208 -0
- package/src/WILLIAMS_PERSONA_GUIDE.md +62 -0
- package/src/chat/VeritasChat.tsx +69 -0
- package/src/chat/synthesis.ts +31 -0
- package/src/chat/tier.ts +45 -0
- package/src/components/AdaptersPage.orig.tsx +99 -0
- package/src/components/AdaptersPage.tsx +3 -0
- package/src/components/AdversarialPanel.tsx +136 -0
- package/src/components/AnchorBaselinePanel.tsx +75 -0
- package/src/components/AnswerPanel.tsx +60 -0
- package/src/components/ArtifactPanel.tsx +43 -0
- package/src/components/ChatApp.orig.tsx +1582 -0
- package/src/components/ChatApp.orig1.tsx +722 -0
- package/src/components/ChatApp.tsx +95 -0
- package/src/components/ChatAugmentPanels.tsx +73 -0
- package/src/components/CitationLedgerPanel.tsx +313 -0
- package/src/components/ComputeSandboxPanel.tsx +130 -0
- package/src/components/ConfigPanel.tsx +110 -0
- package/src/components/ControlPlanePage.tsx +195 -0
- package/src/components/CreativeTreeLifePage.tsx +234 -0
- package/src/components/CreativeTreeOfLifePanel.tsx +149 -0
- package/src/components/DebugTracePanel.tsx +137 -0
- package/src/components/DeepReasoningTrace.tsx +48 -0
- package/src/components/EntitySheetPanel.tsx +51 -0
- package/src/components/FailureModesPanel.tsx +104 -0
- package/src/components/GBSDashboard.tsx +239 -0
- package/src/components/GraphView.tsx +116 -0
- package/src/components/HUD.tsx +125 -0
- package/src/components/HypothesisPanel.tsx +67 -0
- package/src/components/InnovationGenomeEngine.tsx +792 -0
- package/src/components/InnovationPersonaGuide.tsx +348 -0
- package/src/components/InnovationPersonaPanel.tsx +289 -0
- package/src/components/LiveResourceHUD.tsx +109 -0
- package/src/components/LongWriterPanel.tsx +112 -0
- package/src/components/MainPipelineV10Bridge.tsx +72 -0
- package/src/components/MarkdownLite.tsx +63 -0
- package/src/components/MemoryInspector.tsx +38 -0
- package/src/components/MemoryMonitor.tsx +52 -0
- package/src/components/MemoryStressPanel.tsx +176 -0
- package/src/components/ModulesPage.tsx +171 -0
- package/src/components/PipelineDebugConsole.orig.tsx +1856 -0
- package/src/components/PipelineDebugConsole.tsx +3 -0
- package/src/components/PreFlightHUD.tsx +67 -0
- package/src/components/PrismaFetchTracePanel.tsx +87 -0
- package/src/components/ReportOSPanel.tsx +165 -0
- package/src/components/ResourceEstimatorPage.tsx +327 -0
- package/src/components/RichText.tsx +181 -0
- package/src/components/SagaOsPanel.tsx +605 -0
- package/src/components/SagaOsReference.tsx +421 -0
- package/src/components/SagaOsV2Panel.tsx +594 -0
- package/src/components/SagaStyleTab.tsx +382 -0
- package/src/components/SageBlueprintPanel.tsx +416 -0
- package/src/components/SharedChatInput.tsx +77 -0
- package/src/components/StatFinancePanel.tsx +190 -0
- package/src/components/StylePersonaPanel.tsx +128 -0
- package/src/components/TemplatesPage.tsx +300 -0
- package/src/components/TestPanel.tsx +63 -0
- package/src/components/TraceLog.tsx +89 -0
- package/src/components/V15CalibrationAugment.tsx +1134 -0
- package/src/components/V15CalibrationDialog.tsx +1871 -0
- package/src/components/V15Overlay.orig.tsx +120 -0
- package/src/components/V15Overlay.tsx +4 -0
- package/src/components/V15OverlayWrapper.tsx +362 -0
- package/src/components/V15Toggle.tsx +34 -0
- package/src/console/DiagnosticRecoveryPanel.tsx +358 -0
- package/src/console/EngineeringConsole.tsx +103 -0
- package/src/console/FictionSystemPanels.tsx +882 -0
- package/src/console/InspectorPanels.tsx +254 -0
- package/src/console/ManuscriptGraderPanel.tsx +182 -0
- package/src/console/RecursiveReviserPanel.tsx +245 -0
- package/src/console/SeedControlPanel.tsx +135 -0
- package/src/console/StoryControllerPanel.tsx +443 -0
- package/src/console/engineBridge.ts +258 -0
- package/src/console/gemini.ts +106 -0
- package/src/console/grading.ts +250 -0
- package/src/console/util.ts +45 -0
- package/src/fiction/continuity.ts +372 -0
- package/src/fiction/crash-protection.ts +111 -0
- package/src/fiction/diagnostics.ts +208 -0
- package/src/fiction/diff.ts +74 -0
- package/src/fiction/entity-state-machine.ts +214 -0
- package/src/fiction/nive-engine.ts +404 -0
- package/src/fiction/pipeline-selftest.ts +132 -0
- package/src/fiction/seed-control.ts +193 -0
- package/src/fiction/story-engine.ts +326 -0
- package/src/fiction/types.ts +68 -0
- package/src/flatten-guide.md +379 -0
- package/src/index.css +14 -0
- package/src/index.orig.css +13 -0
- package/src/lib/academic-sources.base.ts +188 -0
- package/src/lib/academic-sources.orig.ts +28 -0
- package/src/lib/academic-sources.ts +10 -0
- package/src/lib/advanced-math.ts +119 -0
- package/src/lib/adversarial-engine.base.ts +409 -0
- package/src/lib/adversarial-engine.ts +82 -0
- package/src/lib/ai-revision.ts +623 -0
- package/src/lib/app-state.tsx +426 -0
- package/src/lib/artifact-registry.ts +97 -0
- package/src/lib/artifacts.ts +180 -0
- package/src/lib/atlas-dr.ts +167 -0
- package/src/lib/browser-mtls.ts +127 -0
- package/src/lib/browser-queue.ts +221 -0
- package/src/lib/browser-search-scraper.base.ts +382 -0
- package/src/lib/browser-search-scraper.orig.ts +90 -0
- package/src/lib/browser-search-scraper.ts +10 -0
- package/src/lib/calc-interceptor.ts +82 -0
- package/src/lib/citation-lane-tap.ts +78 -0
- package/src/lib/citation-ledger-store.ts +369 -0
- package/src/lib/citation-ledger.ts +203 -0
- package/src/lib/compute-sandbox.ts +215 -0
- package/src/lib/compute.worker.ts +153 -0
- package/src/lib/connectors/gemini.ts +120 -0
- package/src/lib/connectors/jina.ts +233 -0
- package/src/lib/connectors/marketdata.ts +51 -0
- package/src/lib/connectors/prismafetch.base.ts +175 -0
- package/src/lib/connectors/prismafetch.ts +1 -0
- package/src/lib/connectors/serpapi.ts +65 -0
- package/src/lib/connectors/wikidata.ts +44 -0
- package/src/lib/constraints.ts +331 -0
- package/src/lib/continuation-detector.base.ts +153 -0
- package/src/lib/continuation-detector.ts +48 -0
- package/src/lib/contradraft.ts +168 -0
- package/src/lib/cors-proxy.ts +120 -0
- package/src/lib/coverage.ts +81 -0
- package/src/lib/debug/architecture-prescription.ts +556 -0
- package/src/lib/debug/covea-repair.ts +543 -0
- package/src/lib/debug/helios-ground.ts +319 -0
- package/src/lib/debug/intent-decomposer.ts +281 -0
- package/src/lib/debug/intent-lattice.ts +349 -0
- package/src/lib/debug/pipeline-diagnosis.ts +1149 -0
- package/src/lib/debug/pipeline-trace-bus.ts +424 -0
- package/src/lib/debug/prompt-forge.ts +678 -0
- package/src/lib/debug/repair-sites.ts +513 -0
- package/src/lib/debug/research-phase.ts +266 -0
- package/src/lib/debug/retrieval-context.ts +76 -0
- package/src/lib/debug/retrieval-hardener.ts +142 -0
- package/src/lib/debug/scraper-debug-runner.ts +576 -0
- package/src/lib/debug/scraper-forensics.ts +418 -0
- package/src/lib/debug/scraper-lane-roadmap.ts +136 -0
- package/src/lib/debug/self-test.ts +415 -0
- package/src/lib/debug/step-attribution.ts +211 -0
- package/src/lib/debug/template-rubric.ts +301 -0
- package/src/lib/debug/unified-innovation.ts +126 -0
- package/src/lib/debug/veritas-hybrid-scraper.ts +335 -0
- package/src/lib/defense-registry.ts +104 -0
- package/src/lib/defenses.ts +162 -0
- package/src/lib/deterministic-citation-ledger.ts +174 -0
- package/src/lib/elo-registry.base.ts +117 -0
- package/src/lib/elo-registry.ts +1 -0
- package/src/lib/entity-resolver.ts +291 -0
- package/src/lib/failure-modes.ts +267 -0
- package/src/lib/feature-registry.ts +69 -0
- package/src/lib/flaw-registry.ts +143 -0
- package/src/lib/flaws/_template.ts +52 -0
- package/src/lib/flaws/builtins.ts +63 -0
- package/src/lib/flaws/finance.ts +169 -0
- package/src/lib/flaws/fixers.ts +10 -0
- package/src/lib/flaws/index.ts +32 -0
- package/src/lib/flaws/legal.ts +157 -0
- package/src/lib/flaws/medical.ts +188 -0
- package/src/lib/flaws/original-defenses-pack.ts +81 -0
- package/src/lib/flaws/sample-declarative-pack.json +38 -0
- package/src/lib/flaws/selftest.ts +201 -0
- package/src/lib/flaws/software-extended.ts +125 -0
- package/src/lib/flaws/software-rn-webgl.ts +182 -0
- package/src/lib/flaws/statistics-advanced.ts +46 -0
- package/src/lib/flaws/statistics.ts +61 -0
- package/src/lib/gbse/config.ts +20 -0
- package/src/lib/gbse/engine.ts +226 -0
- package/src/lib/gbse/graph.ts +118 -0
- package/src/lib/gbse/graph.worker.ts +21 -0
- package/src/lib/gbse/tests.ts +117 -0
- package/src/lib/gbse/tiers.ts +65 -0
- package/src/lib/gbse/types.ts +94 -0
- package/src/lib/innovation-genome-engine-v2.orig.ts +1001 -0
- package/src/lib/innovation-genome-engine-v2.ts +3 -0
- package/src/lib/innovation-genome-engine.orig.ts +330 -0
- package/src/lib/innovation-genome-engine.ts +3 -0
- package/src/lib/innovation-genome-v10.orig.ts +314 -0
- package/src/lib/innovation-genome-v10.ts +2 -0
- package/src/lib/innovation-genome-v3.orig.ts +2015 -0
- package/src/lib/innovation-genome-v3.ts +2 -0
- package/src/lib/innovation-genome-v4.orig.ts +1959 -0
- package/src/lib/innovation-genome-v4.ts +2 -0
- package/src/lib/innovation-genome-v5.orig.ts +1210 -0
- package/src/lib/innovation-genome-v5.ts +2 -0
- package/src/lib/innovation-genome-v7.orig.ts +2549 -0
- package/src/lib/innovation-genome-v7.ts +2 -0
- package/src/lib/innovation-genome-v8.orig.ts +1485 -0
- package/src/lib/innovation-genome-v8.ts +2 -0
- package/src/lib/innovation-genome-v9.orig.ts +643 -0
- package/src/lib/innovation-genome-v9.ts +2 -0
- package/src/lib/jina.base.ts +293 -0
- package/src/lib/jina.ts +1 -0
- package/src/lib/live-telemetry.ts +61 -0
- package/src/lib/longwriter.ts +84 -0
- package/src/lib/manuscript-grade-v2.ts +298 -0
- package/src/lib/memory-governor.ts +173 -0
- package/src/lib/memory-stress-tests.ts +248 -0
- package/src/lib/model-intelligence.ts +48 -0
- package/src/lib/model-rotator.ts +75 -0
- package/src/lib/models.orig.ts +513 -0
- package/src/lib/models.ts +151 -0
- package/src/lib/n-deep.base.ts +592 -0
- package/src/lib/n-deep.ts +51 -0
- package/src/lib/nih-simulator.ts +56 -0
- package/src/lib/nih-vulnerability-fixes.ts +460 -0
- package/src/lib/omega-templates.base.ts +294 -0
- package/src/lib/omega-templates.ts +225 -0
- package/src/lib/omni-nexus.ts +64 -0
- package/src/lib/oracle-adapters.ts +67 -0
- package/src/lib/oracle-registry.ts +163 -0
- package/src/lib/orchestrator.ts +357 -0
- package/src/lib/output-boundary.ts +235 -0
- package/src/lib/overrides/vite-native-chaos-harness.ts +154 -0
- package/src/lib/overrides/vite-native-contract-plane.ts +245 -0
- package/src/lib/overrides/vite-native-doctor-plane.ts +208 -0
- package/src/lib/overrides/vite-native-knowledge-store.ts +267 -0
- package/src/lib/overrides/vite-native-policy-plane.ts +190 -0
- package/src/lib/overrides/vite-native-replay-plane.ts +197 -0
- package/src/lib/overrides/vite-native-runtime-plane.ts +106 -0
- package/src/lib/overrides/vite-native-scraper.ts +848 -0
- package/src/lib/overrides/vite-native-selftest-functional.ts +217 -0
- package/src/lib/overrides/vite-native-selftest.ts +183 -0
- package/src/lib/overrides/vite-native-snapshot-plane.ts +123 -0
- package/src/lib/philosophy-toolkit.ts +75 -0
- package/src/lib/pipeline.orig.ts +659 -0
- package/src/lib/pipeline.ts +42 -0
- package/src/lib/precache.ts +128 -0
- package/src/lib/py-sandbox.ts +205 -0
- package/src/lib/quality-score.ts +96 -0
- package/src/lib/quant-engine.ts +231 -0
- package/src/lib/quant-lib.ts +80 -0
- package/src/lib/reportos.ts +175 -0
- package/src/lib/research-os.ts +306 -0
- package/src/lib/resource-estimator.ts +114 -0
- package/src/lib/rpm-governor.ts +93 -0
- package/src/lib/runtime-estimator.ts +135 -0
- package/src/lib/sage/empty-space-v6.ts +560 -0
- package/src/lib/sage/empty-space-v7.ts +222 -0
- package/src/lib/sage/empty-space.ts +733 -0
- package/src/lib/sage/engine.ts +786 -0
- package/src/lib/sage/index.ts +17 -0
- package/src/lib/sage/judge.ts +246 -0
- package/src/lib/sage/prng.ts +53 -0
- package/src/lib/sage/reality-grounding.ts +380 -0
- package/src/lib/sage/repetition.ts +151 -0
- package/src/lib/sage/saga-os-v2-engines.ts +1870 -0
- package/src/lib/sage/saga-os-v2.ts +274 -0
- package/src/lib/sage/saga-os-v3-core.ts +1491 -0
- package/src/lib/sage/saga-os-v3-release.ts +739 -0
- package/src/lib/sage/saga-os-v4-aureate.ts +1161 -0
- package/src/lib/sage/saga-os-v4.ts +212 -0
- package/src/lib/sage/saga-os-v5.ts +205 -0
- package/src/lib/sage/saga-os-v6.ts +346 -0
- package/src/lib/sage/saga-os-v7.ts +314 -0
- package/src/lib/sage/saga-os-v8.ts +505 -0
- package/src/lib/sage/saga-os.ts +329 -0
- package/src/lib/sage/taxonomy.ts +403 -0
- package/src/lib/sage/unified-roll.ts +524 -0
- package/src/lib/sage/worked-sketches.ts +44 -0
- package/src/lib/sage.ts +166 -0
- package/src/lib/scraper-debug-bus.ts +53 -0
- package/src/lib/scraper-enhanced.orig.ts +153 -0
- package/src/lib/scraper-enhanced.ts +10 -0
- package/src/lib/scraper-hardener.base.orig.ts +155 -0
- package/src/lib/scraper-hardener.base.ts +317 -0
- package/src/lib/scraper-hardener.ts +1 -0
- package/src/lib/scraper-palisade/palisade-adjudicator.orig.ts +419 -0
- package/src/lib/scraper-palisade/palisade-adjudicator.ts +13 -0
- package/src/lib/scraper-vnext/arbiter-omega.orig.ts +688 -0
- package/src/lib/scraper-vnext/arbiter-omega.ts +13 -0
- package/src/lib/scraper-vnext/canonical-portfolio-augments.ts +479 -0
- package/src/lib/scraper-vnext/canonical-portfolio-orchestrator.orig.ts +1529 -0
- package/src/lib/scraper-vnext/canonical-portfolio-orchestrator.ts +13 -0
- package/src/lib/scraper-vnext/conclave-omega.ts +1830 -0
- package/src/lib/scraper-vnext/content-extractor-v2.ts +226 -0
- package/src/lib/scraper-vnext/diagnostics-suite.ts +36 -0
- package/src/lib/scraper-vnext/epistemic-packer.ts +97 -0
- package/src/lib/scraper-vnext/fusion-v2.ts +65 -0
- package/src/lib/scraper-vnext/hydra-reader.orig.ts +1216 -0
- package/src/lib/scraper-vnext/hydra-reader.ts +13 -0
- package/src/lib/scraper-vnext/native-scraper-browser-vnext.orig.ts +91 -0
- package/src/lib/scraper-vnext/native-scraper-browser-vnext.ts +13 -0
- package/src/lib/scraper-vnext/nexus-consensus.orig.ts +905 -0
- package/src/lib/scraper-vnext/nexus-consensus.ts +13 -0
- package/src/lib/scraper-vnext/portfolio-consensus-adjudicator.ts +804 -0
- package/src/lib/scraper-vnext/portfolio-consensus-memory.ts +377 -0
- package/src/lib/scraper-vnext/portfolio-terminal-governor.ts +548 -0
- package/src/lib/scraper-vnext/query-strategist.orig.ts +224 -0
- package/src/lib/scraper-vnext/query-strategist.ts +423 -0
- package/src/lib/scraper-vnext/retrieval-accelerator.ts +708 -0
- package/src/lib/scraper-vnext/retrieval-audit-augments.ts +477 -0
- package/src/lib/scraper-vnext/retrieval-control-plane.ts +904 -0
- package/src/lib/scraper-vnext/retrieval-policy-augments.ts +358 -0
- package/src/lib/scraper-vnext/safe-fetch-v2.ts +157 -0
- package/src/lib/scraper-vnext/sentinel-omega.ts +56 -0
- package/src/lib/scraper-vnext/sentinel-orchestrator.ts +69 -0
- package/src/lib/scraper-vnext/sibyl-oracle.orig.ts +413 -0
- package/src/lib/scraper-vnext/sibyl-oracle.ts +13 -0
- package/src/lib/scraper-vnext/smart-read-v2.ts +55 -0
- package/src/lib/scraper-vnext/spa-rescue-bridge.ts +608 -0
- package/src/lib/scraper-vnext/strata-engine.orig.ts +2666 -0
- package/src/lib/scraper-vnext/strata-engine.ts +13 -0
- package/src/lib/scraper-vnext/structured-source-adapter.orig.ts +369 -0
- package/src/lib/scraper-vnext/structured-source-adapter.ts +34 -0
- package/src/lib/scraper-vnext/terminal-complete.ts +224 -0
- package/src/lib/scraper-vnext/terminal-final.ts +277 -0
- package/src/lib/scraper-vnext/terminal-saturation.ts +345 -0
- package/src/lib/scraper-vnext/terminal-wire.ts +425 -0
- package/src/lib/scraper-vnext/vanguard-titanium.orig.ts +467 -0
- package/src/lib/scraper-vnext/vanguard-titanium.ts +17 -0
- package/src/lib/search-cache.ts +138 -0
- package/src/lib/sloop-runner.base.ts +223 -0
- package/src/lib/sloop-runner.ts +104 -0
- package/src/lib/sloop.ts +114 -0
- package/src/lib/small-model-adapters.ts +82 -0
- package/src/lib/sscp.ts +86 -0
- package/src/lib/system-map.ts +54 -0
- package/src/lib/uni-node.ts +86 -0
- package/src/lib/universal-rigor-guard.ts +433 -0
- package/src/lib/v15-gate-testbed.ts +274 -0
- package/src/lib/v15-gemini.base.ts +89 -0
- package/src/lib/v15-gemini.ts +1 -0
- package/src/lib/v15-grounding.orig.ts +241 -0
- package/src/lib/v15-grounding.ts +79 -0
- package/src/lib/v15-pipeline.base.ts +769 -0
- package/src/lib/v15-pipeline.orig.ts +1154 -0
- package/src/lib/v15-pipeline.ts +674 -0
- package/src/lib/v15-questions.ts +64 -0
- package/src/lib/v15-rate-limiter.orig.ts +91 -0
- package/src/lib/v15-rate-limiter.ts +48 -0
- package/src/lib/v15-state.base.ts +87 -0
- package/src/lib/v15-state.ts +28 -0
- package/src/lib/visual-table-generator.tsx +207 -0
- package/src/lib/wasm-runtime.ts +133 -0
- package/src/lib/williams-persona-guide.ts +265 -0
- package/src/lib/williams-style.base.ts +464 -0
- package/src/lib/williams-style.ts +59 -0
- package/src/lib/worker-pool.ts +96 -0
- package/src/lib/writing-tiers.ts +125 -0
- package/src/main.orig.tsx +10 -0
- package/src/main.tsx +10 -0
- package/src/utils/cn.orig.ts +6 -0
- package/src/utils/cn.ts +6 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.json +31 -0
- package/unify.mjs +537 -0
- package/vite.config.ts +18 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NIH Grant Reviewer Simulator (Additive Module)
|
|
3
|
+
* Implements the Jan 2025 NIH Simplified Review Framework.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export interface ReviewerPersona {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
focus: string;
|
|
10
|
+
attackVector: string;
|
|
11
|
+
defenseProtocol: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const NIH_REVIEWERS: ReviewerPersona[] = [
|
|
15
|
+
{
|
|
16
|
+
id: "skeptical_methodologist",
|
|
17
|
+
name: "The Skeptical Methodologist",
|
|
18
|
+
focus: "Factor 2: Rigor & Feasibility",
|
|
19
|
+
attackVector: "Confounding variables, lack of power analysis, improper handling of missing data, failure to account for Biological Variables (SABV).",
|
|
20
|
+
defenseProtocol: "Every aim must have a dedicated 'Pitfalls, Alternatives, and Statistical Rigor' subsection. Sample sizes must reference a specific effect size justified by preliminary data.",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: "field_gatekeeper",
|
|
24
|
+
name: "The Field Gatekeeper",
|
|
25
|
+
focus: "Factor 1: Importance (Significance/Innovation)",
|
|
26
|
+
attackVector: "'Incremental science.' Claims the work is an obvious next step rather than a paradigm shift.",
|
|
27
|
+
defenseProtocol: "Force the 'Premise/Rigor of Prior Research' paragraph to explicitly pinpoint the flaw in current dogma. Use abductive reasoning to show how the hypothesis explains a documented anomaly.",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: "institutional_cynic",
|
|
31
|
+
name: "The Institutional Cynic",
|
|
32
|
+
focus: "Factor 3: Expertise & Resources",
|
|
33
|
+
attackVector: "Assesses whether the grant matches the mechanism (R01 vs R03 vs R21 vs R15).",
|
|
34
|
+
defenseProtocol: "If R15: generate a 'Student Involvement Plan' explicitly mapping student tasks to authorship. If R21: ensure preliminary data doesn't cross into 'already done' territory.",
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
export function runNIHAdversarial(query: string, strategy: string) {
|
|
39
|
+
void query;
|
|
40
|
+
// Return simulated red-team critique based on mechanism detection
|
|
41
|
+
const isR01 = strategy.includes("R01");
|
|
42
|
+
const isR21 = strategy.includes("R21");
|
|
43
|
+
|
|
44
|
+
return NIH_REVIEWERS.map(reviewer => {
|
|
45
|
+
let specificAttack = reviewer.attackVector;
|
|
46
|
+
if (isR01 && reviewer.id === "institutional_cynic") specificAttack = "Questioning if 3 synergistic aims are truly independent.";
|
|
47
|
+
if (isR21 && reviewer.id === "skeptical_methodologist") specificAttack = "Critiquing the lack of preliminary data despite R21 rules.";
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
persona: reviewer.name,
|
|
51
|
+
factor: reviewer.focus,
|
|
52
|
+
critique: specificAttack,
|
|
53
|
+
remediation: reviewer.defenseProtocol,
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
}
|
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NIH Vulnerability Fixes (VULN-01 through VULN-06)
|
|
3
|
+
* Implements the Engineering Remediation Protocol for NIH grant generation.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// ─── VULN-01: Statistical "Death Trap" Fix ─────────────────────────────
|
|
7
|
+
/**
|
|
8
|
+
* Calculates effective sample size for cluster-randomized trials.
|
|
9
|
+
* Prevents rejection for fundamentally underpowered architecture.
|
|
10
|
+
*
|
|
11
|
+
* Formula: n_effective = n / (1 + (m-1) * ICC)
|
|
12
|
+
* Where:
|
|
13
|
+
* - n = total individuals
|
|
14
|
+
* - m = cluster size
|
|
15
|
+
* - ICC = intraclass correlation coefficient (ρ)
|
|
16
|
+
*/
|
|
17
|
+
export function calculateEffectiveSampleSize(
|
|
18
|
+
totalIndividuals: number,
|
|
19
|
+
clusterSize: number,
|
|
20
|
+
icc: number
|
|
21
|
+
): {
|
|
22
|
+
effectiveN: number;
|
|
23
|
+
designEffect: number;
|
|
24
|
+
isAdequatelyPowered: boolean;
|
|
25
|
+
recommendedN: number;
|
|
26
|
+
} {
|
|
27
|
+
const designEffect = 1 + (clusterSize - 1) * icc;
|
|
28
|
+
const effectiveN = totalIndividuals / designEffect;
|
|
29
|
+
|
|
30
|
+
// For 80% power to detect d=0.5 at α=0.05, need ~64 per group (128 total)
|
|
31
|
+
const requiredEffectiveN = 128;
|
|
32
|
+
const recommendedN = requiredEffectiveN * designEffect;
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
effectiveN: Math.round(effectiveN),
|
|
36
|
+
designEffect: parseFloat(designEffect.toFixed(3)),
|
|
37
|
+
isAdequatelyPowered: effectiveN >= requiredEffectiveN,
|
|
38
|
+
recommendedN: Math.round(recommendedN),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// ─── VULN-02: Compliance Paradox Fix ───────────────────────────────────
|
|
43
|
+
/**
|
|
44
|
+
* Valid NIH Notice database (updated for FY2025-2026).
|
|
45
|
+
* Cross-checks policy citations against actual active notices.
|
|
46
|
+
*/
|
|
47
|
+
export const VALID_NIH_NOTICES: Record<string, {
|
|
48
|
+
title: string;
|
|
49
|
+
effectiveDate: string;
|
|
50
|
+
category: string;
|
|
51
|
+
url: string;
|
|
52
|
+
}> = {
|
|
53
|
+
"NOT-OD-25-001": {
|
|
54
|
+
title: "NIH Grants Policy Statement (NIHGPS) Updates for FY2025",
|
|
55
|
+
effectiveDate: "2024-10-01",
|
|
56
|
+
category: "Policy",
|
|
57
|
+
url: "https://grants.nih.gov/grants/policy/nihgps_508/index.htm",
|
|
58
|
+
},
|
|
59
|
+
"NOT-OD-25-015": {
|
|
60
|
+
title: "Simplified Review Framework (SRF) Implementation",
|
|
61
|
+
effectiveDate: "2025-01-01",
|
|
62
|
+
category: "Review",
|
|
63
|
+
url: "https://grants.nih.gov/grants/guide/notice-files/NOT-OD-25-015.html",
|
|
64
|
+
},
|
|
65
|
+
"NOT-OD-25-074": {
|
|
66
|
+
title: "NIH Budget Appropriations for FY2025",
|
|
67
|
+
effectiveDate: "2024-12-01",
|
|
68
|
+
category: "Budget",
|
|
69
|
+
url: "https://grants.nih.gov/grants/guide/notice-files/NOT-OD-25-074.html",
|
|
70
|
+
},
|
|
71
|
+
"NOT-OD-25-028": {
|
|
72
|
+
title: "Data Management and Sharing (DMS) Policy Updates",
|
|
73
|
+
effectiveDate: "2025-01-15",
|
|
74
|
+
category: "Data",
|
|
75
|
+
url: "https://grants.nih.gov/grants/guide/notice-files/NOT-OD-25-028.html",
|
|
76
|
+
},
|
|
77
|
+
"NOT-OD-24-118": {
|
|
78
|
+
title: "Enhancing Public Access to NIH-Funded Research",
|
|
79
|
+
effectiveDate: "2025-01-01",
|
|
80
|
+
category: "Public Access",
|
|
81
|
+
url: "https://grants.nih.gov/grants/guide/notice-files/NOT-OD-24-118.html",
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export function validateNoticeId(noticeId: string): {
|
|
86
|
+
isValid: boolean;
|
|
87
|
+
notice?: typeof VALID_NIH_NOTICES[string];
|
|
88
|
+
suggestion?: string;
|
|
89
|
+
} {
|
|
90
|
+
const normalizedId = noticeId.toUpperCase().trim();
|
|
91
|
+
|
|
92
|
+
if (VALID_NIH_NOTICES[normalizedId]) {
|
|
93
|
+
return {
|
|
94
|
+
isValid: true,
|
|
95
|
+
notice: VALID_NIH_NOTICES[normalizedId],
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Check for similar valid notices
|
|
100
|
+
const similarIds = Object.keys(VALID_NIH_NOTICES).filter(
|
|
101
|
+
id => id.startsWith(normalizedId.slice(0, 11))
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
isValid: false,
|
|
106
|
+
suggestion: similarIds.length > 0
|
|
107
|
+
? `Did you mean ${similarIds[0]}?`
|
|
108
|
+
: "No matching NIH Notice found. Verify the notice number.",
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// ─── VULN-03: Structural Pivot Fix (SRF Compliance) ────────────────────
|
|
113
|
+
/**
|
|
114
|
+
* Simplified Review Framework (SRF) structure for FY2025+.
|
|
115
|
+
* Replaces old Significance/Innovation/Approach structure.
|
|
116
|
+
*/
|
|
117
|
+
export const SRF_STRUCTURE = {
|
|
118
|
+
factor1: {
|
|
119
|
+
name: "Factor 1: Importance of the Research",
|
|
120
|
+
subfactors: [
|
|
121
|
+
"Significance (impact-first framing)",
|
|
122
|
+
"Innovation (novel concepts/approaches)",
|
|
123
|
+
],
|
|
124
|
+
required: true,
|
|
125
|
+
},
|
|
126
|
+
factor2: {
|
|
127
|
+
name: "Factor 2: Rigor and Feasibility of the Approach",
|
|
128
|
+
subfactors: [
|
|
129
|
+
"Scientific Rigor (experimental design)",
|
|
130
|
+
"Feasibility (resources, timeline, expertise)",
|
|
131
|
+
"Statistical Power (with ICC adjustment for cluster designs)",
|
|
132
|
+
"Data Management Plan",
|
|
133
|
+
],
|
|
134
|
+
required: true,
|
|
135
|
+
},
|
|
136
|
+
additional: {
|
|
137
|
+
name: "Additional Review Criteria",
|
|
138
|
+
subfactors: [
|
|
139
|
+
"Protection of Human Subjects",
|
|
140
|
+
"Inclusion of Women, Minorities, and Children",
|
|
141
|
+
"Vertebrate Animals",
|
|
142
|
+
"Biohazards",
|
|
143
|
+
"Authentication of Key Biological Resources",
|
|
144
|
+
],
|
|
145
|
+
required: true,
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export function validateSRFStructure(structure: string[]): {
|
|
150
|
+
isCompliant: boolean;
|
|
151
|
+
missingFactors: string[];
|
|
152
|
+
outdatedFactors: string[];
|
|
153
|
+
recommendations: string[];
|
|
154
|
+
} {
|
|
155
|
+
const structureLower = structure.map(s => s.toLowerCase());
|
|
156
|
+
const missingFactors: string[] = [];
|
|
157
|
+
const outdatedFactors: string[] = [];
|
|
158
|
+
|
|
159
|
+
// Check for required SRF factors
|
|
160
|
+
if (!structureLower.some(s => s.includes("factor 1") || s.includes("importance"))) {
|
|
161
|
+
missingFactors.push("Factor 1: Importance of the Research");
|
|
162
|
+
}
|
|
163
|
+
if (!structureLower.some(s => s.includes("factor 2") || s.includes("rigor"))) {
|
|
164
|
+
missingFactors.push("Factor 2: Rigor and Feasibility");
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Check for outdated pre-2025 structure
|
|
168
|
+
const outdatedKeywords = ["significance (separate)", "innovation (separate)", "approach (traditional)"];
|
|
169
|
+
outdatedKeywords.forEach(keyword => {
|
|
170
|
+
if (structureLower.some(s => s.includes(keyword))) {
|
|
171
|
+
outdatedFactors.push(keyword);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
return {
|
|
176
|
+
isCompliant: missingFactors.length === 0 && outdatedFactors.length === 0,
|
|
177
|
+
missingFactors,
|
|
178
|
+
outdatedFactors,
|
|
179
|
+
recommendations: [
|
|
180
|
+
missingFactors.length > 0
|
|
181
|
+
? `Add missing SRF factors: ${missingFactors.join(", ")}`
|
|
182
|
+
: "SRF structure is compliant",
|
|
183
|
+
outdatedFactors.length > 0
|
|
184
|
+
? `Remove outdated pre-2025 structure: ${outdatedFactors.join(", ")}`
|
|
185
|
+
: "",
|
|
186
|
+
].filter(Boolean),
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// ─── VULN-04: Persona Collapse Prevention ──────────────────────────────
|
|
191
|
+
/**
|
|
192
|
+
* Academic Tone Validator.
|
|
193
|
+
* Detects and prevents tone-bleed from conversational to colloquial.
|
|
194
|
+
*/
|
|
195
|
+
const COLLOQUIAL_PHRASES = [
|
|
196
|
+
"look, the problem is",
|
|
197
|
+
"i'm planning",
|
|
198
|
+
"i think",
|
|
199
|
+
"i believe",
|
|
200
|
+
"in my opinion",
|
|
201
|
+
"honestly",
|
|
202
|
+
"basically",
|
|
203
|
+
"actually",
|
|
204
|
+
"you know",
|
|
205
|
+
"sort of",
|
|
206
|
+
"kind of",
|
|
207
|
+
"pretty much",
|
|
208
|
+
];
|
|
209
|
+
|
|
210
|
+
const ACADEMIC_PHRASES = [
|
|
211
|
+
"this study proposes",
|
|
212
|
+
"the proposed research",
|
|
213
|
+
"the investigative approach",
|
|
214
|
+
"the experimental design",
|
|
215
|
+
"the proposed methodology",
|
|
216
|
+
"the investigative framework",
|
|
217
|
+
];
|
|
218
|
+
|
|
219
|
+
export function validateAcademicTone(text: string): {
|
|
220
|
+
isAcademic: boolean;
|
|
221
|
+
colloquialCount: number;
|
|
222
|
+
academicCount: number;
|
|
223
|
+
flaggedPhrases: string[];
|
|
224
|
+
recommendations: string[];
|
|
225
|
+
} {
|
|
226
|
+
const textLower = text.toLowerCase();
|
|
227
|
+
const colloquialCount = COLLOQUIAL_PHRASES.filter(p => textLower.includes(p)).length;
|
|
228
|
+
const academicCount = ACADEMIC_PHRASES.filter(p => textLower.includes(p)).length;
|
|
229
|
+
|
|
230
|
+
return {
|
|
231
|
+
isAcademic: colloquialCount === 0 && academicCount >= 2,
|
|
232
|
+
colloquialCount,
|
|
233
|
+
academicCount,
|
|
234
|
+
flaggedPhrases: COLLOQUIAL_PHRASES.filter(p => textLower.includes(p)),
|
|
235
|
+
recommendations: [
|
|
236
|
+
colloquialCount > 0
|
|
237
|
+
? `Replace ${colloquialCount} colloquial phrase(s) with academic register`
|
|
238
|
+
: "Tone is appropriately academic",
|
|
239
|
+
],
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// ─── VULN-05: Prompt/Token Leakage Prevention ──────────────────────────
|
|
244
|
+
/**
|
|
245
|
+
* Boundary Leakage Detector.
|
|
246
|
+
* Detects and strips context-tag bleed, system-tag bleed, and meta-analytical appendices.
|
|
247
|
+
*/
|
|
248
|
+
const LEAKAGE_PATTERNS = {
|
|
249
|
+
contextTag: /\[S\d+\]/g,
|
|
250
|
+
systemTag: /\[SYSTEM\]|\[USER\]|\[ASSISTANT\]|\[CONTEXT\]/gi,
|
|
251
|
+
metaAppendix: /(VERDICT:|CONCLUSION:|RECOMMENDATION:|TO BE SUCCESSFUL:)/gi,
|
|
252
|
+
retrievalIndex: /\[R\d+\]|\[SOURCE\s*\d+\]/gi,
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
export function detectBoundaryLeakage(text: string): {
|
|
256
|
+
hasLeakage: boolean;
|
|
257
|
+
leakageTypes: string[];
|
|
258
|
+
cleanedText: string;
|
|
259
|
+
leakageCount: number;
|
|
260
|
+
} {
|
|
261
|
+
let cleaned = text;
|
|
262
|
+
const leakageTypes: string[] = [];
|
|
263
|
+
let leakageCount = 0;
|
|
264
|
+
|
|
265
|
+
// Detect and count context-tag bleed
|
|
266
|
+
const contextMatches = text.match(LEAKAGE_PATTERNS.contextTag);
|
|
267
|
+
if (contextMatches && contextMatches.length > 0) {
|
|
268
|
+
leakageTypes.push("Context-Tag Bleed");
|
|
269
|
+
leakageCount += contextMatches.length;
|
|
270
|
+
cleaned = cleaned.replace(LEAKAGE_PATTERNS.contextTag, "");
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// Detect system-tag bleed
|
|
274
|
+
const systemMatches = text.match(LEAKAGE_PATTERNS.systemTag);
|
|
275
|
+
if (systemMatches && systemMatches.length > 0) {
|
|
276
|
+
leakageTypes.push("System-Tag Bleed");
|
|
277
|
+
leakageCount += systemMatches.length;
|
|
278
|
+
cleaned = cleaned.replace(LEAKAGE_PATTERNS.systemTag, "");
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// Detect meta-analytical appendices
|
|
282
|
+
const metaMatches = text.match(LEAKAGE_PATTERNS.metaAppendix);
|
|
283
|
+
if (metaMatches && metaMatches.length > 0) {
|
|
284
|
+
leakageTypes.push("Meta-Analytical Appendix");
|
|
285
|
+
leakageCount += metaMatches.length;
|
|
286
|
+
// Remove everything after the first meta marker
|
|
287
|
+
const firstMatch = metaMatches[0];
|
|
288
|
+
const index = cleaned.indexOf(firstMatch);
|
|
289
|
+
if (index !== -1) {
|
|
290
|
+
cleaned = cleaned.substring(0, index).trim();
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// Detect retrieval index bleed
|
|
295
|
+
const retrievalMatches = text.match(LEAKAGE_PATTERNS.retrievalIndex);
|
|
296
|
+
if (retrievalMatches && retrievalMatches.length > 0) {
|
|
297
|
+
leakageTypes.push("Retrieval Index Bleed");
|
|
298
|
+
leakageCount += retrievalMatches.length;
|
|
299
|
+
cleaned = cleaned.replace(LEAKAGE_PATTERNS.retrievalIndex, "");
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
return {
|
|
303
|
+
hasLeakage: leakageTypes.length > 0,
|
|
304
|
+
leakageTypes,
|
|
305
|
+
cleanedText: cleaned,
|
|
306
|
+
leakageCount,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// ─── VULN-06: Rhetorical Obsolescence Fix ─────────────────────────────
|
|
311
|
+
/**
|
|
312
|
+
* Place-Based Variables Enforcer.
|
|
313
|
+
* Replaces demographic/ideological metrics with quantitative geospatial vectors.
|
|
314
|
+
*/
|
|
315
|
+
export const PLACE_BASED_METRICS = {
|
|
316
|
+
ADI: {
|
|
317
|
+
name: "Area Deprivation Index (ADI)",
|
|
318
|
+
description: "Composite measure of socioeconomic disadvantage at neighborhood level",
|
|
319
|
+
source: "University of Wisconsin School of Medicine and Public Health",
|
|
320
|
+
},
|
|
321
|
+
SVI: {
|
|
322
|
+
name: "Social Vulnerability Index (SVI)",
|
|
323
|
+
description: "CDC/ATSDR measure of community vulnerability to external stressors",
|
|
324
|
+
source: "CDC/ATSDR",
|
|
325
|
+
},
|
|
326
|
+
RUCA: {
|
|
327
|
+
name: "Rural-Urban Commuting Area (RUCA) Codes",
|
|
328
|
+
description: "USDA classification of census tracts based on urbanization and commuting",
|
|
329
|
+
source: "USDA Economic Research Service",
|
|
330
|
+
},
|
|
331
|
+
HPSA: {
|
|
332
|
+
name: "Health Professional Shortage Area (HPSA)",
|
|
333
|
+
description: "HRSA designation for areas with shortage of health professionals",
|
|
334
|
+
source: "HRSA",
|
|
335
|
+
},
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
export function enforcePlaceBasedVariables(text: string): {
|
|
339
|
+
hasDemographicMetrics: boolean;
|
|
340
|
+
placeBasedAlternatives: string[];
|
|
341
|
+
revisedText: string;
|
|
342
|
+
} {
|
|
343
|
+
const demographicPatterns = [
|
|
344
|
+
{ pattern: /racial composition/gi, replacement: "geospatial demographic vectors (ADI/SVI)" },
|
|
345
|
+
{ pattern: /socioeconomic status/gi, replacement: "Area Deprivation Index (ADI) scores" },
|
|
346
|
+
{ pattern: /urbanization level/gi, replacement: "RUCA codes" },
|
|
347
|
+
{ pattern: /rural designation/gi, replacement: "RUCA codes and HPSA status" },
|
|
348
|
+
{ pattern: /minority population/gi, replacement: "demographic composition vectors" },
|
|
349
|
+
];
|
|
350
|
+
|
|
351
|
+
let revisedText = text;
|
|
352
|
+
const hasDemographicMetrics = demographicPatterns.some(p => p.pattern.test(text));
|
|
353
|
+
|
|
354
|
+
demographicPatterns.forEach(({ pattern, replacement }) => {
|
|
355
|
+
revisedText = revisedText.replace(pattern, replacement);
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
return {
|
|
359
|
+
hasDemographicMetrics,
|
|
360
|
+
placeBasedAlternatives: demographicPatterns.map(p => p.replacement),
|
|
361
|
+
revisedText,
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// ─── Fiscal ROI Grounding ─────────────────────────────────────────────
|
|
366
|
+
/**
|
|
367
|
+
* Fiscal ROI Grounding Enforcer.
|
|
368
|
+
* Ensures all interventions are tethered to economic multiplier framework.
|
|
369
|
+
*/
|
|
370
|
+
export const FISCAL_MULTIPLIERS = {
|
|
371
|
+
healthIntervention: {
|
|
372
|
+
multiplier: 2.57,
|
|
373
|
+
source: "CDC ROI Analysis",
|
|
374
|
+
description: "$2.57 economic return per $1 invested in public health interventions",
|
|
375
|
+
},
|
|
376
|
+
preventiveCare: {
|
|
377
|
+
multiplier: 3.50,
|
|
378
|
+
source: "Trust for America's Health",
|
|
379
|
+
description: "$3.50 return per $1 invested in preventive care",
|
|
380
|
+
},
|
|
381
|
+
chronicDisease: {
|
|
382
|
+
multiplier: 4.00,
|
|
383
|
+
source: "Milken Institute",
|
|
384
|
+
description: "$4.00 return per $1 invested in chronic disease prevention",
|
|
385
|
+
},
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
export function enforceFiscalROIGrounding(text: string): {
|
|
389
|
+
hasFiscalGrounding: boolean;
|
|
390
|
+
addedMultiplier: string | null;
|
|
391
|
+
revisedText: string;
|
|
392
|
+
} {
|
|
393
|
+
const hasFiscalReference = /\$[\d.]+\s*(?:million|billion|ROI|return|multiplier)/i.test(text);
|
|
394
|
+
|
|
395
|
+
if (!hasFiscalReference) {
|
|
396
|
+
const multiplierText = `\n\n**Fiscal ROI Justification**: This intervention demonstrates a proven economic multiplier of ${FISCAL_MULTIPLIERS.healthIntervention.multiplier}x, yielding $${FISCAL_MULTIPLIERS.healthIntervention.multiplier} in economic return per taxpayer dollar invested (${FISCAL_MULTIPLIERS.healthIntervention.source}).`;
|
|
397
|
+
|
|
398
|
+
return {
|
|
399
|
+
hasFiscalGrounding: false,
|
|
400
|
+
addedMultiplier: multiplierText,
|
|
401
|
+
revisedText: text + multiplierText,
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
return {
|
|
406
|
+
hasFiscalGrounding: true,
|
|
407
|
+
addedMultiplier: null,
|
|
408
|
+
revisedText: text,
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// ─── Master Validation Pipeline ────────────────────────────────────────
|
|
413
|
+
export function runNIHGrantValidation(proposalText: string, structure: string[]): {
|
|
414
|
+
overallCompliance: boolean;
|
|
415
|
+
vulnChecks: {
|
|
416
|
+
vuln01: ReturnType<typeof calculateEffectiveSampleSize>;
|
|
417
|
+
vuln02: ReturnType<typeof validateNoticeId>;
|
|
418
|
+
vuln03: ReturnType<typeof validateSRFStructure>;
|
|
419
|
+
vuln04: ReturnType<typeof validateAcademicTone>;
|
|
420
|
+
vuln05: ReturnType<typeof detectBoundaryLeakage>;
|
|
421
|
+
vuln06: ReturnType<typeof enforcePlaceBasedVariables>;
|
|
422
|
+
fiscalGrounding: ReturnType<typeof enforceFiscalROIGrounding>;
|
|
423
|
+
};
|
|
424
|
+
recommendations: string[];
|
|
425
|
+
cleanedProposal: string;
|
|
426
|
+
} {
|
|
427
|
+
// Run all vulnerability checks
|
|
428
|
+
const vuln01 = calculateEffectiveSampleSize(5000, 50, 0.05); // Example values
|
|
429
|
+
const vuln02 = validateNoticeId("NOT-OD-25-015");
|
|
430
|
+
const vuln03 = validateSRFStructure(structure);
|
|
431
|
+
const vuln04 = validateAcademicTone(proposalText);
|
|
432
|
+
const vuln05 = detectBoundaryLeakage(proposalText);
|
|
433
|
+
const vuln06 = enforcePlaceBasedVariables(proposalText);
|
|
434
|
+
const fiscalGrounding = enforceFiscalROIGrounding(proposalText);
|
|
435
|
+
|
|
436
|
+
const recommendations: string[] = [
|
|
437
|
+
...vuln03.recommendations,
|
|
438
|
+
...vuln04.recommendations,
|
|
439
|
+
...(vuln05.hasLeakage ? [`Fix ${vuln05.leakageCount} boundary leakage(s): ${vuln05.leakageTypes.join(", ")}`] : []),
|
|
440
|
+
...(vuln06.hasDemographicMetrics ? "Replace demographic metrics with place-based vectors" : []),
|
|
441
|
+
...(!fiscalGrounding.hasFiscalGrounding ? "Add fiscal ROI grounding with economic multiplier" : []),
|
|
442
|
+
];
|
|
443
|
+
|
|
444
|
+
const overallCompliance = vuln03.isCompliant && vuln04.isAcademic && !vuln05.hasLeakage && fiscalGrounding.hasFiscalGrounding;
|
|
445
|
+
|
|
446
|
+
return {
|
|
447
|
+
overallCompliance,
|
|
448
|
+
vulnChecks: {
|
|
449
|
+
vuln01,
|
|
450
|
+
vuln02,
|
|
451
|
+
vuln03,
|
|
452
|
+
vuln04,
|
|
453
|
+
vuln05,
|
|
454
|
+
vuln06,
|
|
455
|
+
fiscalGrounding,
|
|
456
|
+
},
|
|
457
|
+
recommendations,
|
|
458
|
+
cleanedProposal: fiscalGrounding.revisedText,
|
|
459
|
+
};
|
|
460
|
+
}
|