axiom-scigraph 0.1.0__tar.gz
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.
- axiom_scigraph-0.1.0/LICENSE +21 -0
- axiom_scigraph-0.1.0/PKG-INFO +277 -0
- axiom_scigraph-0.1.0/README.md +249 -0
- axiom_scigraph-0.1.0/pyproject.toml +82 -0
- axiom_scigraph-0.1.0/setup.cfg +4 -0
- axiom_scigraph-0.1.0/src/axiom_scigraph.egg-info/PKG-INFO +277 -0
- axiom_scigraph-0.1.0/src/axiom_scigraph.egg-info/SOURCES.txt +104 -0
- axiom_scigraph-0.1.0/src/axiom_scigraph.egg-info/dependency_links.txt +1 -0
- axiom_scigraph-0.1.0/src/axiom_scigraph.egg-info/entry_points.txt +2 -0
- axiom_scigraph-0.1.0/src/axiom_scigraph.egg-info/requires.txt +12 -0
- axiom_scigraph-0.1.0/src/axiom_scigraph.egg-info/top_level.txt +5 -0
- axiom_scigraph-0.1.0/src/evals/__init__.py +17 -0
- axiom_scigraph-0.1.0/src/evals/benchmark.py +1343 -0
- axiom_scigraph-0.1.0/src/evals/py.typed +0 -0
- axiom_scigraph-0.1.0/src/graph/__init__.py +33 -0
- axiom_scigraph-0.1.0/src/graph/canonicalizer.py +141 -0
- axiom_scigraph-0.1.0/src/graph/claim_graph.py +489 -0
- axiom_scigraph-0.1.0/src/graph/py.typed +0 -0
- axiom_scigraph-0.1.0/src/graph/scoring.py +435 -0
- axiom_scigraph-0.1.0/src/graph/store.py +737 -0
- axiom_scigraph-0.1.0/src/ingest/__init__.py +71 -0
- axiom_scigraph-0.1.0/src/ingest/connectors.py +515 -0
- axiom_scigraph-0.1.0/src/ingest/corpus_loader.py +179 -0
- axiom_scigraph-0.1.0/src/ingest/extractor.py +493 -0
- axiom_scigraph-0.1.0/src/ingest/open_access_corpus.py +259 -0
- axiom_scigraph-0.1.0/src/ingest/providers.py +511 -0
- axiom_scigraph-0.1.0/src/ingest/py.typed +0 -0
- axiom_scigraph-0.1.0/src/ingest/tabular.py +242 -0
- axiom_scigraph-0.1.0/src/ingest/verifier.py +832 -0
- axiom_scigraph-0.1.0/src/scigraph/__init__.py +129 -0
- axiom_scigraph-0.1.0/src/scigraph/adjudication.py +407 -0
- axiom_scigraph-0.1.0/src/scigraph/alerts.py +195 -0
- axiom_scigraph-0.1.0/src/scigraph/cli.py +1007 -0
- axiom_scigraph-0.1.0/src/scigraph/cli_handlers.py +1589 -0
- axiom_scigraph-0.1.0/src/scigraph/config.py +58 -0
- axiom_scigraph-0.1.0/src/scigraph/demo.py +62 -0
- axiom_scigraph-0.1.0/src/scigraph/diagrams.py +241 -0
- axiom_scigraph-0.1.0/src/scigraph/diff.py +164 -0
- axiom_scigraph-0.1.0/src/scigraph/dirwatch.py +146 -0
- axiom_scigraph-0.1.0/src/scigraph/doctor.py +164 -0
- axiom_scigraph-0.1.0/src/scigraph/explorer.py +685 -0
- axiom_scigraph-0.1.0/src/scigraph/exporters.py +264 -0
- axiom_scigraph-0.1.0/src/scigraph/io_utils.py +165 -0
- axiom_scigraph-0.1.0/src/scigraph/mcp_server.py +885 -0
- axiom_scigraph-0.1.0/src/scigraph/models.py +475 -0
- axiom_scigraph-0.1.0/src/scigraph/net_guard.py +89 -0
- axiom_scigraph-0.1.0/src/scigraph/pipeline.py +232 -0
- axiom_scigraph-0.1.0/src/scigraph/provenance.py +195 -0
- axiom_scigraph-0.1.0/src/scigraph/py.typed +0 -0
- axiom_scigraph-0.1.0/src/scigraph/security.py +213 -0
- axiom_scigraph-0.1.0/src/scigraph/server.py +1962 -0
- axiom_scigraph-0.1.0/src/scigraph/signatures.py +121 -0
- axiom_scigraph-0.1.0/src/scigraph/status.py +180 -0
- axiom_scigraph-0.1.0/src/scigraph/watch.py +438 -0
- axiom_scigraph-0.1.0/src/scigraph/workspace.py +1606 -0
- axiom_scigraph-0.1.0/src/solver/__init__.py +45 -0
- axiom_scigraph-0.1.0/src/solver/prioritizer.py +114 -0
- axiom_scigraph-0.1.0/src/solver/protocols.py +165 -0
- axiom_scigraph-0.1.0/src/solver/py.typed +0 -0
- axiom_scigraph-0.1.0/src/solver/regime.py +164 -0
- axiom_scigraph-0.1.0/src/solver/symbolic.py +260 -0
- axiom_scigraph-0.1.0/tests/test_adjudication.py +884 -0
- axiom_scigraph-0.1.0/tests/test_alerts.py +279 -0
- axiom_scigraph-0.1.0/tests/test_canonicalizer.py +240 -0
- axiom_scigraph-0.1.0/tests/test_cli_delight.py +413 -0
- axiom_scigraph-0.1.0/tests/test_cli_extended.py +188 -0
- axiom_scigraph-0.1.0/tests/test_cli_wave4.py +498 -0
- axiom_scigraph-0.1.0/tests/test_cli_wave5.py +373 -0
- axiom_scigraph-0.1.0/tests/test_cli_wave6.py +410 -0
- axiom_scigraph-0.1.0/tests/test_cli_wave7.py +247 -0
- axiom_scigraph-0.1.0/tests/test_config.py +380 -0
- axiom_scigraph-0.1.0/tests/test_connectors.py +449 -0
- axiom_scigraph-0.1.0/tests/test_corpus_tabular_wire.py +149 -0
- axiom_scigraph-0.1.0/tests/test_diagrams.py +343 -0
- axiom_scigraph-0.1.0/tests/test_diff_and_bib.py +282 -0
- axiom_scigraph-0.1.0/tests/test_doctor.py +92 -0
- axiom_scigraph-0.1.0/tests/test_e2e_enterprise.py +263 -0
- axiom_scigraph-0.1.0/tests/test_evidence_weighting.py +402 -0
- axiom_scigraph-0.1.0/tests/test_exp_c_ingest.py +584 -0
- axiom_scigraph-0.1.0/tests/test_explorer_a11y.py +138 -0
- axiom_scigraph-0.1.0/tests/test_exporters_perf.py +245 -0
- axiom_scigraph-0.1.0/tests/test_graph_store.py +428 -0
- axiom_scigraph-0.1.0/tests/test_ingest_real_pdf.py +228 -0
- axiom_scigraph-0.1.0/tests/test_io_utils.py +92 -0
- axiom_scigraph-0.1.0/tests/test_load_stress.py +116 -0
- axiom_scigraph-0.1.0/tests/test_mcp_server.py +532 -0
- axiom_scigraph-0.1.0/tests/test_net_guard.py +181 -0
- axiom_scigraph-0.1.0/tests/test_pipeline.py +186 -0
- axiom_scigraph-0.1.0/tests/test_prioritizer.py +383 -0
- axiom_scigraph-0.1.0/tests/test_protocols.py +384 -0
- axiom_scigraph-0.1.0/tests/test_provenance.py +279 -0
- axiom_scigraph-0.1.0/tests/test_providers.py +638 -0
- axiom_scigraph-0.1.0/tests/test_regime_extended.py +109 -0
- axiom_scigraph-0.1.0/tests/test_scale_perf.py +150 -0
- axiom_scigraph-0.1.0/tests/test_scigraph.py +500 -0
- axiom_scigraph-0.1.0/tests/test_scoring.py +463 -0
- axiom_scigraph-0.1.0/tests/test_security.py +348 -0
- axiom_scigraph-0.1.0/tests/test_server.py +796 -0
- axiom_scigraph-0.1.0/tests/test_server_security.py +310 -0
- axiom_scigraph-0.1.0/tests/test_server_ui.py +279 -0
- axiom_scigraph-0.1.0/tests/test_server_workspace.py +645 -0
- axiom_scigraph-0.1.0/tests/test_ship_review_fixes.py +3783 -0
- axiom_scigraph-0.1.0/tests/test_smoke.py +5 -0
- axiom_scigraph-0.1.0/tests/test_tabular_ingest.py +265 -0
- axiom_scigraph-0.1.0/tests/test_watch_registry.py +652 -0
- axiom_scigraph-0.1.0/tests/test_workspace.py +984 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Justin Mafie
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: axiom-scigraph
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: SciGraph: Neuro-Symbolic Scientific Discovery & Reasoning Engine
|
|
5
|
+
Author: Justin Mafie
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Repository, https://github.com/creova-gif/scigraph
|
|
8
|
+
Project-URL: Homepage, https://github.com/creova-gif/scigraph
|
|
9
|
+
Keywords: scientific-discovery,neuro-symbolic,claim-graph,contradiction-detection,sarif,cli,reproducibility
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering
|
|
15
|
+
Requires-Python: >=3.12
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: pydantic>=2.9
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
21
|
+
Requires-Dist: mypy>=1.10; extra == "dev"
|
|
22
|
+
Requires-Dist: ruff>=0.6; extra == "dev"
|
|
23
|
+
Provides-Extra: mcp
|
|
24
|
+
Requires-Dist: mcp<3,>=2.3; extra == "mcp"
|
|
25
|
+
Provides-Extra: llm
|
|
26
|
+
Requires-Dist: openai<2,>=1.50; extra == "llm"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# SciGraph: Neuro-Symbolic Scientific Discovery & Reasoning Engine
|
|
30
|
+
|
|
31
|
+
[](https://github.com/creova-gif/scigraph/actions/workflows/ci.yml)
|
|
32
|
+
[](LICENSE)
|
|
33
|
+
[](pyproject.toml)
|
|
34
|
+
[](pyproject.toml)
|
|
35
|
+
[](pyproject.toml)
|
|
36
|
+
|
|
37
|
+
SciGraph ingests multi-column scientific PDFs, structured JSON, CSV/TSV screening tables, and PubMed XML corpora, extracts typed `(Intervention, Condition, Outcome)` claim tuples with verbatim evidence spans, verifies that every quote, p-value, and sample size exists verbatim in the source text (and that a parsed-text DOI appears verbatim, where the DOI came from the text rather than connector metadata), and resolves cross-paper contradictions into falsifiable experiments through a symbolic constraint solver.
|
|
38
|
+
|
|
39
|
+
- **Spec:** [PROJECT_SPEC.md](PROJECT_SPEC.md)
|
|
40
|
+
- **Architecture and threat model:** See `AGENTS.md`, `docs/adr/001-typed-claim-tuples-and-verbatim-evidence-verification.md`, and `docs/THREAT_MODEL.md`.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Architecture
|
|
45
|
+
|
|
46
|
+
```mermaid
|
|
47
|
+
flowchart LR
|
|
48
|
+
Sources["Sources: PDF / JSON / CSV / TSV / PubMed XML / arXiv / EuropePMC"] --> Ingest["Layout-Aware Ingestion & Verbatim Verifier"]
|
|
49
|
+
Ingest -->|"Verified Claims Only"| Graph["ClaimGraph & EntityCanonicalizer"]
|
|
50
|
+
Graph -->|"SQLite / JSON"| Store["Persistent Store & Multi-Tenant Workspaces"]
|
|
51
|
+
Graph --> Solver["Symbolic Contradiction, Regime & Power Solver"]
|
|
52
|
+
Solver --> Outputs["Reports (MD / HTML / SARIF / JSON), Mermaid / DOT Diagrams & Lab Protocols"]
|
|
53
|
+
Store --> API["SciGraphApp HTTP / OpenAPI 3.1.0 Server (RBAC + Rate Limit)"]
|
|
54
|
+
Store --> Prov["SHA-256 / HMAC-SHA256 Provenance & Webhook Alerts"]
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
- **Domain Models (`src/scigraph/models.py`)**: Strict, frozen Pydantic v2 models (`ConfigDict(strict=True, frozen=True, extra="forbid")`) for `Paper`, `PaperSection`, `LayoutBlock`, `EvidenceSpan`, `ClaimTuple`, `StatisticalEvidence`, `ScientificClaim`, `EvidenceEdge`, `ContradictionPair`, and `FalsifiableExperiment`.
|
|
58
|
+
- **Threat Model & ADRs**: See [`docs/THREAT_MODEL.md`](docs/THREAT_MODEL.md), [`AGENTS.md`](AGENTS.md), and [`docs/adr/`](docs/adr/).
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Key Capabilities
|
|
63
|
+
|
|
64
|
+
### 1. Ingestion & Verbatim Verification
|
|
65
|
+
- **Multi-format corpus loading (`src/ingest/`)**: Orders two-column PDF layout blocks in reading order (`order_layout_blocks`, `extract_paper_from_pdf_bytes` with `/FlateDecode` stream support), alongside `.json`, `.csv`/`.tsv` (`load_papers_from_csv`), and PubMed EFetch `<PubmedArticleSet>` `.xml` (`parse_pubmed_efetch_xml`).
|
|
66
|
+
- **SSRF-guarded literature connectors (`src/ingest/connectors.py`)**: Fetches arXiv Atom XML (`fetch_arxiv_papers`) and EuropePMC JSON (`fetch_europepmc_papers`) over `https://` with non-public IP SSRF guards and a `10 MiB` response cap (`MAX_RESPONSE_BYTES`).
|
|
67
|
+
- **Deterministic verbatim verifier**: Rejects any extracted claim whose verbatim quote slice, p-value string, or sample size `n` does not match the source text verbatim; DOI verbatim presence is checked only when `Paper.doi_provenance` is `parsed` — connector-supplied and synthesized fallback DOIs are declared `connector_metadata`/`fabricated` and never treated as verbatim-verified (`verify_claim_verbatim`).
|
|
68
|
+
|
|
69
|
+
### 2. Claim Graph & Canonicalization
|
|
70
|
+
- **Verified graph boundary (`src/graph/claim_graph.py`)**: Stores verified papers and claims, rejects unverified claims at the boundary, and builds `SUPPORTS`, `REPLICATES`, `CONTRADICTS`, and `QUALIFIES` edges across papers sharing normalized `(intervention, outcome)` pairs.
|
|
71
|
+
- **Evidence scoring & consensus (`src/graph/scoring.py`)**: Scores claims into `HIGH` / `MODERATE` / `PRELIMINARY` evidence tiers (`score_claim_evidence`) and aggregates directional consensus per `(intervention, outcome)` topic (`compute_topic_consensus`).
|
|
72
|
+
- **Non-destructive canonicalization (`src/graph/canonicalizer.py`)**: Normalizes `ClaimTuple` intervention, condition, and outcome aliases via `EntityCanonicalizer` (`DEFAULT_SCIENTIFIC_ALIASES`) while preserving verbatim `EvidenceSpan` offsets and surfacing multi-surface-form clusters (`find_canonical_clusters`).
|
|
73
|
+
|
|
74
|
+
### 3. Symbolic Contradiction & Regime/Power Solver
|
|
75
|
+
- **Unsatisfiable core isolation (`src/solver/symbolic.py`)**: Maps claim effect directions into discrete constraints (`{-1, 0, +1}`) and isolates unsatisfiable cores (`check_claim_set_satisfiability`, `detect_contradictions`).
|
|
76
|
+
- **Regime & power calibration (`src/solver/regime.py`)**: Computes quantitative physical/chemical regime deltas (`compute_regime_delta`) and proposes effect-size-calibrated `FalsifiableExperiment` designs (`propose_falsifiable_experiments`).
|
|
77
|
+
- **Experiment ROI & lab protocols (`src/solver/prioritizer.py`, `src/solver/protocols.py`)**: Ranks proposals via `prioritize_experiments` (`LOW` / `MEDIUM` / `HIGH` participant cost tiers) and generates 4-phase (`PRE_REGISTRATION`, `RANDOMIZATION`, `MEASUREMENT`, `STATISTICAL_ANALYSIS`) `ExperimentProtocol` sheets (`generate_experiment_protocols`, `render_protocols_markdown`).
|
|
78
|
+
|
|
79
|
+
### 4. Reporting & Diagrams
|
|
80
|
+
- **Multi-format reports (`src/scigraph/exporters.py`, `src/scigraph/explorer.py`)**: Emits Markdown, JSON, OASIS SARIF v2.1.0 CI diagnostics, and an XSS-safe interactive HTML Claim-Graph Explorer with atomic `--output` writes.
|
|
81
|
+
- **Graph diagrams & references (`src/scigraph/diagrams.py`, `src/scigraph/diff.py`)**: Exports `ClaimGraph` conflicts to Mermaid (`export_mermaid_flowchart`) or Graphviz DOT (`export_graphviz_dot`), diffs baseline vs. current snapshots (`diff_claim_graphs`), and exports deterministic BibTeX (`export_bibtex`) or RIS (`export_ris`) bibliographies.
|
|
82
|
+
|
|
83
|
+
### 5. Multi-Tenant Workspaces
|
|
84
|
+
- **Isolated tenant stores (`src/scigraph/workspace.py`)**: `WorkspaceManager` isolates `(org_id, workspace_id)` tenants with slug and `is_relative_to` path-traversal guards, per-workspace `graph.db` SQLite stores, and append-only `audit.jsonl` logs.
|
|
85
|
+
- **Batch orchestration & webhooks (`src/scigraph/pipeline.py`, `src/scigraph/alerts.py`)**: Declarative `run_pipeline` orchestrator (`PipelineConfig` -> `PipelineSummary`) and SSRF-guarded Slack-compatible webhook notifications (`build_alert_payload`, `dispatch_webhook_alert`).
|
|
86
|
+
|
|
87
|
+
### 6. Provenance & REST/OpenAPI Server
|
|
88
|
+
- **Cryptographic provenance (`src/scigraph/provenance.py`)**: Builds (`build_provenance_manifest`) and verifies (`verify_provenance_manifest`) canonical SHA-256 and optional HMAC-SHA256 manifests over `ClaimGraph` papers, claims, and chained `audit.jsonl` logs.
|
|
89
|
+
- **Zero-dependency HTTP/OpenAPI server (`src/scigraph/server.py`, `src/scigraph/security.py`)**: `SciGraphApp` (`ThreadingHTTPServer`) with OpenAPI 3.1.0 schema (`/openapi.json`), constant-time Bearer-token RBAC (`AuthGate`, `load_token_policies`), thread-safe `SlidingWindowRateLimiter`, `2 MiB` body cap, `nosniff`/`no-store` headers, and workspace persistence (`POST /api/v1/verify?persist=true`).
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Installation & Configuration
|
|
94
|
+
|
|
95
|
+
SciGraph requires **Python 3.12+** and **Pydantic v2** (`>=2.9`).
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# Install with uv (recommended)
|
|
99
|
+
uv sync --extra dev
|
|
100
|
+
|
|
101
|
+
# Or install with pip in a virtual environment
|
|
102
|
+
python3.12 -m venv .venv
|
|
103
|
+
source .venv/bin/activate
|
|
104
|
+
pip install -e ".[dev]"
|
|
105
|
+
|
|
106
|
+
# Or install standalone with pipx (exposes the `scigraph` console script)
|
|
107
|
+
pipx install axiom-scigraph
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Configuration (`scigraph.toml`)
|
|
111
|
+
|
|
112
|
+
SciGraph loads optional project configuration from `scigraph.toml` in the working directory (or via `--path`). Both `[scigraph]`-table and top-level keys are supported and validated strictly by `SciGraphConfig`:
|
|
113
|
+
|
|
114
|
+
```toml
|
|
115
|
+
[scigraph]
|
|
116
|
+
default_store = "scigraph.db"
|
|
117
|
+
workspace_root = ".scigraph/workspaces"
|
|
118
|
+
default_org = "research-lab"
|
|
119
|
+
server_host = "127.0.0.1"
|
|
120
|
+
server_port = 8765
|
|
121
|
+
rate_limit = 120
|
|
122
|
+
rate_window_seconds = 60.0
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Inspect the active configuration at any time:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
scigraph config
|
|
129
|
+
scigraph config --path scigraph.toml --json
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## CLI Quickstart
|
|
135
|
+
|
|
136
|
+
Run with `scigraph <subcommand>` (or `PYTHONPATH=src .venv/bin/python -m scigraph.cli <subcommand>`).
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
# Version & system diagnostics
|
|
140
|
+
scigraph --version
|
|
141
|
+
scigraph doctor --json
|
|
142
|
+
|
|
143
|
+
# Configuration inspection
|
|
144
|
+
scigraph config --json
|
|
145
|
+
|
|
146
|
+
# 30-paper benchmark & verification
|
|
147
|
+
scigraph benchmark --json
|
|
148
|
+
scigraph verify --input path/to/corpus/
|
|
149
|
+
|
|
150
|
+
# Reporting (markdown, html, sarif, json)
|
|
151
|
+
scigraph report --input path/to/corpus/ --format html --output scigraph-studio.html
|
|
152
|
+
scigraph report --input path/to/corpus/ --format sarif --output scigraph.sarif --fail-on-contradictions
|
|
153
|
+
scigraph report --input path/to/corpus/ --format html --open # render + open in browser
|
|
154
|
+
|
|
155
|
+
# Guided demo & live directory watching (stdlib polling, not inotify)
|
|
156
|
+
scigraph demo --workspace .scigraph-demo
|
|
157
|
+
scigraph watch ./inbox --root .workspaces --org acme --workspace cardio
|
|
158
|
+
scigraph watch ./inbox --root .workspaces --org acme --workspace cardio --once
|
|
159
|
+
|
|
160
|
+
# Store/workspace health dashboard (read-only)
|
|
161
|
+
scigraph status --root .workspaces --json
|
|
162
|
+
scigraph status --store scigraph.db
|
|
163
|
+
|
|
164
|
+
# Persistent ingestion, querying & graph diffing
|
|
165
|
+
scigraph ingest path/to/corpus/ --store scigraph.db
|
|
166
|
+
scigraph query --store scigraph.db --intervention "metformin" --direction increases --json
|
|
167
|
+
scigraph diff --baseline baseline.db --current scigraph.db --json
|
|
168
|
+
|
|
169
|
+
# Consensus scoring, canonicalization, prioritization & lab protocols
|
|
170
|
+
scigraph consensus --store scigraph.db --json
|
|
171
|
+
scigraph canonicalize --store scigraph.db --json
|
|
172
|
+
scigraph prioritize --store scigraph.db --json
|
|
173
|
+
scigraph protocols --store scigraph.db --output protocols.md
|
|
174
|
+
|
|
175
|
+
# Diagrams & reference export
|
|
176
|
+
scigraph diagram --store scigraph.db --format mermaid --output graph.mmd
|
|
177
|
+
scigraph diagram --store scigraph.db --format graphml --output graph.graphml
|
|
178
|
+
scigraph export-refs --store scigraph.db --format bibtex --output refs.bib
|
|
179
|
+
|
|
180
|
+
# Multi-tenant workspaces
|
|
181
|
+
scigraph workspace init --root .workspaces --org acme --workspace cardio --name "Cardio Workspace"
|
|
182
|
+
scigraph workspace ingest --root .workspaces --org acme --workspace cardio --input path/to/corpus/
|
|
183
|
+
scigraph workspace audit --root .workspaces --org acme --workspace cardio
|
|
184
|
+
scigraph workspace export-bundle --root .workspaces --org acme --workspace cardio --output bundle/
|
|
185
|
+
scigraph workspace remove-paper --root .workspaces --org acme --workspace cardio --paper-id paper-001 --json
|
|
186
|
+
scigraph workspace adjudicate --root .workspaces --org acme --workspace cardio --signature "drugx|fatigue|reaction time|decreases+increases|direct_direction_conflict" --verdict dismiss --actor reviewer-1
|
|
187
|
+
scigraph workspace adjudications --root .workspaces --org acme --workspace cardio
|
|
188
|
+
|
|
189
|
+
# Literature connectors, provenance, batch pipeline & webhook alerts
|
|
190
|
+
scigraph fetch --source arxiv --query "metformin longevity" --output arxiv.json
|
|
191
|
+
scigraph provenance build --store scigraph.db --output manifest.json
|
|
192
|
+
scigraph provenance verify --store scigraph.db --manifest manifest.json
|
|
193
|
+
scigraph pipeline --input path/to/corpus/ --store scigraph.db --report-dir reports/
|
|
194
|
+
scigraph alert --store scigraph.db --json
|
|
195
|
+
|
|
196
|
+
# Local HTTP / OpenAPI 3.1.0 server
|
|
197
|
+
scigraph serve --store scigraph.db --host 127.0.0.1 --port 8765
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### HTTP / OpenAPI Server Endpoints
|
|
201
|
+
|
|
202
|
+
| Method & Path | Description |
|
|
203
|
+
| --- | --- |
|
|
204
|
+
| `GET /` | Interactive HTML Claim-Graph Explorer (WCAG 2.1 AA) |
|
|
205
|
+
| `GET /health`, `HEAD /health` | Liveness and store status check |
|
|
206
|
+
| `GET /metrics` | Server and graph operational metrics |
|
|
207
|
+
| `GET /openapi.json` | OpenAPI 3.1.0 specification |
|
|
208
|
+
| `GET /api/v1/papers` | List papers in the graph (`?paper_id=`, `?include_full_text=`) |
|
|
209
|
+
| `GET /api/v1/claims` | Query verified `ScientificClaim` records |
|
|
210
|
+
| `GET /api/v1/contradictions` | List detected `ContradictionPair` conflicts |
|
|
211
|
+
| `GET /api/v1/consensus` | Compute topic-level directional consensus and claim scores |
|
|
212
|
+
| `GET /api/v1/prioritize` | Rank falsifiable experiment proposals by ROI |
|
|
213
|
+
| `GET /api/v1/audit` | Read workspace audit events |
|
|
214
|
+
| `GET /api/v1/adjudications` | List contradiction adjudication records (reader+) |
|
|
215
|
+
| `POST /api/v1/adjudications` | Create an adjudication (`uphold`/`dismiss`/`split`; adjudicator+ role) |
|
|
216
|
+
| `GET /api/v1/report` | Generate structured contradiction & experiment report |
|
|
217
|
+
| `POST /api/v1/verify` | Verify submitted papers/claims (`?persist=true` with workspace binding) |
|
|
218
|
+
| `DELETE /api/v1/papers/{paper_id}` | Remove a paper and its claims from the bound workspace |
|
|
219
|
+
|
|
220
|
+
### MCP Server (optional extra)
|
|
221
|
+
|
|
222
|
+
SciGraph exposes an [MCP](https://modelcontextprotocol.io) tool surface so agents can call verify/query/report/adjudicate natively. It adapts the same `SciGraphApp` dispatch as the REST server — identical authz and validation — and requires the optional extra:
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
pip install 'axiom-scigraph[mcp]' # core install stays stdlib + pydantic only
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
# stdio transport (local agent launch; see auth note below)
|
|
230
|
+
scigraph mcp --store scigraph.db
|
|
231
|
+
|
|
232
|
+
# streamable-http transport (per-call Bearer token required with --tokens)
|
|
233
|
+
scigraph mcp --transport streamable-http --tokens policies.json --host 127.0.0.1 --port 8766 \
|
|
234
|
+
--workspace-root ./workspaces --org acme --workspace main
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Tools: `scigraph_health`, `scigraph_list_claims`, `scigraph_list_papers`, `scigraph_get_paper`, `scigraph_contradictions`, `scigraph_consensus`, `scigraph_prioritize`, `scigraph_report`, `scigraph_adjudications`, `scigraph_audit`, `scigraph_adjudicate` (adjudicator+ role), `scigraph_verify_papers` (ingestor+ role for `persist=true`).
|
|
238
|
+
|
|
239
|
+
**Auth boundary:** stdio carries no per-call `Authorization` — it is a local trust boundary; supply a static token via `--bearer-token`/`--bearer-token-file` or `SCIGRAPH_MCP_BEARER_TOKEN(_FILE)` when `--tokens` policies are configured (otherwise calls fail closed with 401). Streamable HTTP requires a per-call `Authorization: Bearer` header validated against the same token policies; non-loopback binds require `--tokens`. Full threat model: [`docs/adr/011-mcp-surface.md`](docs/adr/011-mcp-surface.md).
|
|
240
|
+
|
|
241
|
+
### Deployment & Security
|
|
242
|
+
|
|
243
|
+
- **Containerization**: Build and run with [`Dockerfile`](Dockerfile) and configure environment variables using [`.env.example`](.env.example).
|
|
244
|
+
- **Security Policy**: See [`SECURITY.md`](SECURITY.md) for vulnerability reporting and hardening guidance.
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Reproducible Benchmark Metrics
|
|
249
|
+
|
|
250
|
+
Measured on Python 3.12 across the 30-paper benchmark corpus (`src/evals/benchmark.py`), including 5 open-access arXiv and PubMed two-column PDF streams (`src/ingest/open_access_corpus.py`) and 150 adversarial decoy claims containing fabricated DOIs, p-values, sample sizes, and quote spans:
|
|
251
|
+
|
|
252
|
+
| Metric | Target Threshold | Measured Result | Verification |
|
|
253
|
+
| --- | --- | --- | --- |
|
|
254
|
+
| Structured claim-tuple extraction F1 | >= 0.85 | **1.0000** (60 TP, 0 FP, 0 FN) | `test_30_paper_benchmark_exceeds_acceptance_thresholds` |
|
|
255
|
+
| Fabricated DOIs accepted | 0 | **0** (30 / 30 fabricated DOI decoys rejected) | `test_deterministic_verifier_rejects_fabricated_doi_p_value_and_sample_size` |
|
|
256
|
+
| Fabricated p-values accepted | 0 | **0** (120 / 120 fabricated p-value, sample-size, and span decoys rejected) | `test_30_paper_benchmark_exceeds_acceptance_thresholds` |
|
|
257
|
+
| End-to-end 30-paper pipeline latency (median) | Deterministic local run | **3.415 ms** (range 2.793 to 4.120 ms across 7 runs) | Bound by regex tokenization and Pydantic v2 validation on 1 core |
|
|
258
|
+
|
|
259
|
+
Fabricated-DOI rejection works by provenance, not by checking synthesized text against itself: papers carry `doi_provenance` (`parsed` / `connector_metadata` / `fabricated`), the verbatim DOI check runs only on genuinely parsed text, and any DOI in the reserved `10.0000/*` fallback namespace is force-marked `fabricated`. Decoy claims are rejected on claim-vs-paper DOI mismatch regardless of the paper-level check.
|
|
260
|
+
|
|
261
|
+
Regenerate locally and run the full quality gate:
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
.venv/bin/ruff check src tests
|
|
265
|
+
.venv/bin/mypy --strict src tests
|
|
266
|
+
.venv/bin/pytest -v
|
|
267
|
+
PYTHONPATH=src .venv/bin/python -m scigraph.cli benchmark
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
## Contributing & License
|
|
273
|
+
|
|
274
|
+
- **Contributing**: See [`CONTRIBUTING.md`](CONTRIBUTING.md) for development setup, coding standards (`ruff`, `mypy --strict`, `pytest`), and PR guidelines.
|
|
275
|
+
- **Changelog**: See [`CHANGELOG.md`](CHANGELOG.md) for release history.
|
|
276
|
+
- **Architecture Decision Records**: See [`docs/adr/`](docs/adr/) for design rationale (`001` through `007`).
|
|
277
|
+
- **License**: Released under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
# SciGraph: Neuro-Symbolic Scientific Discovery & Reasoning Engine
|
|
2
|
+
|
|
3
|
+
[](https://github.com/creova-gif/scigraph/actions/workflows/ci.yml)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](pyproject.toml)
|
|
6
|
+
[](pyproject.toml)
|
|
7
|
+
[](pyproject.toml)
|
|
8
|
+
|
|
9
|
+
SciGraph ingests multi-column scientific PDFs, structured JSON, CSV/TSV screening tables, and PubMed XML corpora, extracts typed `(Intervention, Condition, Outcome)` claim tuples with verbatim evidence spans, verifies that every quote, p-value, and sample size exists verbatim in the source text (and that a parsed-text DOI appears verbatim, where the DOI came from the text rather than connector metadata), and resolves cross-paper contradictions into falsifiable experiments through a symbolic constraint solver.
|
|
10
|
+
|
|
11
|
+
- **Spec:** [PROJECT_SPEC.md](PROJECT_SPEC.md)
|
|
12
|
+
- **Architecture and threat model:** See `AGENTS.md`, `docs/adr/001-typed-claim-tuples-and-verbatim-evidence-verification.md`, and `docs/THREAT_MODEL.md`.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Architecture
|
|
17
|
+
|
|
18
|
+
```mermaid
|
|
19
|
+
flowchart LR
|
|
20
|
+
Sources["Sources: PDF / JSON / CSV / TSV / PubMed XML / arXiv / EuropePMC"] --> Ingest["Layout-Aware Ingestion & Verbatim Verifier"]
|
|
21
|
+
Ingest -->|"Verified Claims Only"| Graph["ClaimGraph & EntityCanonicalizer"]
|
|
22
|
+
Graph -->|"SQLite / JSON"| Store["Persistent Store & Multi-Tenant Workspaces"]
|
|
23
|
+
Graph --> Solver["Symbolic Contradiction, Regime & Power Solver"]
|
|
24
|
+
Solver --> Outputs["Reports (MD / HTML / SARIF / JSON), Mermaid / DOT Diagrams & Lab Protocols"]
|
|
25
|
+
Store --> API["SciGraphApp HTTP / OpenAPI 3.1.0 Server (RBAC + Rate Limit)"]
|
|
26
|
+
Store --> Prov["SHA-256 / HMAC-SHA256 Provenance & Webhook Alerts"]
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
- **Domain Models (`src/scigraph/models.py`)**: Strict, frozen Pydantic v2 models (`ConfigDict(strict=True, frozen=True, extra="forbid")`) for `Paper`, `PaperSection`, `LayoutBlock`, `EvidenceSpan`, `ClaimTuple`, `StatisticalEvidence`, `ScientificClaim`, `EvidenceEdge`, `ContradictionPair`, and `FalsifiableExperiment`.
|
|
30
|
+
- **Threat Model & ADRs**: See [`docs/THREAT_MODEL.md`](docs/THREAT_MODEL.md), [`AGENTS.md`](AGENTS.md), and [`docs/adr/`](docs/adr/).
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Key Capabilities
|
|
35
|
+
|
|
36
|
+
### 1. Ingestion & Verbatim Verification
|
|
37
|
+
- **Multi-format corpus loading (`src/ingest/`)**: Orders two-column PDF layout blocks in reading order (`order_layout_blocks`, `extract_paper_from_pdf_bytes` with `/FlateDecode` stream support), alongside `.json`, `.csv`/`.tsv` (`load_papers_from_csv`), and PubMed EFetch `<PubmedArticleSet>` `.xml` (`parse_pubmed_efetch_xml`).
|
|
38
|
+
- **SSRF-guarded literature connectors (`src/ingest/connectors.py`)**: Fetches arXiv Atom XML (`fetch_arxiv_papers`) and EuropePMC JSON (`fetch_europepmc_papers`) over `https://` with non-public IP SSRF guards and a `10 MiB` response cap (`MAX_RESPONSE_BYTES`).
|
|
39
|
+
- **Deterministic verbatim verifier**: Rejects any extracted claim whose verbatim quote slice, p-value string, or sample size `n` does not match the source text verbatim; DOI verbatim presence is checked only when `Paper.doi_provenance` is `parsed` — connector-supplied and synthesized fallback DOIs are declared `connector_metadata`/`fabricated` and never treated as verbatim-verified (`verify_claim_verbatim`).
|
|
40
|
+
|
|
41
|
+
### 2. Claim Graph & Canonicalization
|
|
42
|
+
- **Verified graph boundary (`src/graph/claim_graph.py`)**: Stores verified papers and claims, rejects unverified claims at the boundary, and builds `SUPPORTS`, `REPLICATES`, `CONTRADICTS`, and `QUALIFIES` edges across papers sharing normalized `(intervention, outcome)` pairs.
|
|
43
|
+
- **Evidence scoring & consensus (`src/graph/scoring.py`)**: Scores claims into `HIGH` / `MODERATE` / `PRELIMINARY` evidence tiers (`score_claim_evidence`) and aggregates directional consensus per `(intervention, outcome)` topic (`compute_topic_consensus`).
|
|
44
|
+
- **Non-destructive canonicalization (`src/graph/canonicalizer.py`)**: Normalizes `ClaimTuple` intervention, condition, and outcome aliases via `EntityCanonicalizer` (`DEFAULT_SCIENTIFIC_ALIASES`) while preserving verbatim `EvidenceSpan` offsets and surfacing multi-surface-form clusters (`find_canonical_clusters`).
|
|
45
|
+
|
|
46
|
+
### 3. Symbolic Contradiction & Regime/Power Solver
|
|
47
|
+
- **Unsatisfiable core isolation (`src/solver/symbolic.py`)**: Maps claim effect directions into discrete constraints (`{-1, 0, +1}`) and isolates unsatisfiable cores (`check_claim_set_satisfiability`, `detect_contradictions`).
|
|
48
|
+
- **Regime & power calibration (`src/solver/regime.py`)**: Computes quantitative physical/chemical regime deltas (`compute_regime_delta`) and proposes effect-size-calibrated `FalsifiableExperiment` designs (`propose_falsifiable_experiments`).
|
|
49
|
+
- **Experiment ROI & lab protocols (`src/solver/prioritizer.py`, `src/solver/protocols.py`)**: Ranks proposals via `prioritize_experiments` (`LOW` / `MEDIUM` / `HIGH` participant cost tiers) and generates 4-phase (`PRE_REGISTRATION`, `RANDOMIZATION`, `MEASUREMENT`, `STATISTICAL_ANALYSIS`) `ExperimentProtocol` sheets (`generate_experiment_protocols`, `render_protocols_markdown`).
|
|
50
|
+
|
|
51
|
+
### 4. Reporting & Diagrams
|
|
52
|
+
- **Multi-format reports (`src/scigraph/exporters.py`, `src/scigraph/explorer.py`)**: Emits Markdown, JSON, OASIS SARIF v2.1.0 CI diagnostics, and an XSS-safe interactive HTML Claim-Graph Explorer with atomic `--output` writes.
|
|
53
|
+
- **Graph diagrams & references (`src/scigraph/diagrams.py`, `src/scigraph/diff.py`)**: Exports `ClaimGraph` conflicts to Mermaid (`export_mermaid_flowchart`) or Graphviz DOT (`export_graphviz_dot`), diffs baseline vs. current snapshots (`diff_claim_graphs`), and exports deterministic BibTeX (`export_bibtex`) or RIS (`export_ris`) bibliographies.
|
|
54
|
+
|
|
55
|
+
### 5. Multi-Tenant Workspaces
|
|
56
|
+
- **Isolated tenant stores (`src/scigraph/workspace.py`)**: `WorkspaceManager` isolates `(org_id, workspace_id)` tenants with slug and `is_relative_to` path-traversal guards, per-workspace `graph.db` SQLite stores, and append-only `audit.jsonl` logs.
|
|
57
|
+
- **Batch orchestration & webhooks (`src/scigraph/pipeline.py`, `src/scigraph/alerts.py`)**: Declarative `run_pipeline` orchestrator (`PipelineConfig` -> `PipelineSummary`) and SSRF-guarded Slack-compatible webhook notifications (`build_alert_payload`, `dispatch_webhook_alert`).
|
|
58
|
+
|
|
59
|
+
### 6. Provenance & REST/OpenAPI Server
|
|
60
|
+
- **Cryptographic provenance (`src/scigraph/provenance.py`)**: Builds (`build_provenance_manifest`) and verifies (`verify_provenance_manifest`) canonical SHA-256 and optional HMAC-SHA256 manifests over `ClaimGraph` papers, claims, and chained `audit.jsonl` logs.
|
|
61
|
+
- **Zero-dependency HTTP/OpenAPI server (`src/scigraph/server.py`, `src/scigraph/security.py`)**: `SciGraphApp` (`ThreadingHTTPServer`) with OpenAPI 3.1.0 schema (`/openapi.json`), constant-time Bearer-token RBAC (`AuthGate`, `load_token_policies`), thread-safe `SlidingWindowRateLimiter`, `2 MiB` body cap, `nosniff`/`no-store` headers, and workspace persistence (`POST /api/v1/verify?persist=true`).
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Installation & Configuration
|
|
66
|
+
|
|
67
|
+
SciGraph requires **Python 3.12+** and **Pydantic v2** (`>=2.9`).
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# Install with uv (recommended)
|
|
71
|
+
uv sync --extra dev
|
|
72
|
+
|
|
73
|
+
# Or install with pip in a virtual environment
|
|
74
|
+
python3.12 -m venv .venv
|
|
75
|
+
source .venv/bin/activate
|
|
76
|
+
pip install -e ".[dev]"
|
|
77
|
+
|
|
78
|
+
# Or install standalone with pipx (exposes the `scigraph` console script)
|
|
79
|
+
pipx install axiom-scigraph
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Configuration (`scigraph.toml`)
|
|
83
|
+
|
|
84
|
+
SciGraph loads optional project configuration from `scigraph.toml` in the working directory (or via `--path`). Both `[scigraph]`-table and top-level keys are supported and validated strictly by `SciGraphConfig`:
|
|
85
|
+
|
|
86
|
+
```toml
|
|
87
|
+
[scigraph]
|
|
88
|
+
default_store = "scigraph.db"
|
|
89
|
+
workspace_root = ".scigraph/workspaces"
|
|
90
|
+
default_org = "research-lab"
|
|
91
|
+
server_host = "127.0.0.1"
|
|
92
|
+
server_port = 8765
|
|
93
|
+
rate_limit = 120
|
|
94
|
+
rate_window_seconds = 60.0
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Inspect the active configuration at any time:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
scigraph config
|
|
101
|
+
scigraph config --path scigraph.toml --json
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## CLI Quickstart
|
|
107
|
+
|
|
108
|
+
Run with `scigraph <subcommand>` (or `PYTHONPATH=src .venv/bin/python -m scigraph.cli <subcommand>`).
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Version & system diagnostics
|
|
112
|
+
scigraph --version
|
|
113
|
+
scigraph doctor --json
|
|
114
|
+
|
|
115
|
+
# Configuration inspection
|
|
116
|
+
scigraph config --json
|
|
117
|
+
|
|
118
|
+
# 30-paper benchmark & verification
|
|
119
|
+
scigraph benchmark --json
|
|
120
|
+
scigraph verify --input path/to/corpus/
|
|
121
|
+
|
|
122
|
+
# Reporting (markdown, html, sarif, json)
|
|
123
|
+
scigraph report --input path/to/corpus/ --format html --output scigraph-studio.html
|
|
124
|
+
scigraph report --input path/to/corpus/ --format sarif --output scigraph.sarif --fail-on-contradictions
|
|
125
|
+
scigraph report --input path/to/corpus/ --format html --open # render + open in browser
|
|
126
|
+
|
|
127
|
+
# Guided demo & live directory watching (stdlib polling, not inotify)
|
|
128
|
+
scigraph demo --workspace .scigraph-demo
|
|
129
|
+
scigraph watch ./inbox --root .workspaces --org acme --workspace cardio
|
|
130
|
+
scigraph watch ./inbox --root .workspaces --org acme --workspace cardio --once
|
|
131
|
+
|
|
132
|
+
# Store/workspace health dashboard (read-only)
|
|
133
|
+
scigraph status --root .workspaces --json
|
|
134
|
+
scigraph status --store scigraph.db
|
|
135
|
+
|
|
136
|
+
# Persistent ingestion, querying & graph diffing
|
|
137
|
+
scigraph ingest path/to/corpus/ --store scigraph.db
|
|
138
|
+
scigraph query --store scigraph.db --intervention "metformin" --direction increases --json
|
|
139
|
+
scigraph diff --baseline baseline.db --current scigraph.db --json
|
|
140
|
+
|
|
141
|
+
# Consensus scoring, canonicalization, prioritization & lab protocols
|
|
142
|
+
scigraph consensus --store scigraph.db --json
|
|
143
|
+
scigraph canonicalize --store scigraph.db --json
|
|
144
|
+
scigraph prioritize --store scigraph.db --json
|
|
145
|
+
scigraph protocols --store scigraph.db --output protocols.md
|
|
146
|
+
|
|
147
|
+
# Diagrams & reference export
|
|
148
|
+
scigraph diagram --store scigraph.db --format mermaid --output graph.mmd
|
|
149
|
+
scigraph diagram --store scigraph.db --format graphml --output graph.graphml
|
|
150
|
+
scigraph export-refs --store scigraph.db --format bibtex --output refs.bib
|
|
151
|
+
|
|
152
|
+
# Multi-tenant workspaces
|
|
153
|
+
scigraph workspace init --root .workspaces --org acme --workspace cardio --name "Cardio Workspace"
|
|
154
|
+
scigraph workspace ingest --root .workspaces --org acme --workspace cardio --input path/to/corpus/
|
|
155
|
+
scigraph workspace audit --root .workspaces --org acme --workspace cardio
|
|
156
|
+
scigraph workspace export-bundle --root .workspaces --org acme --workspace cardio --output bundle/
|
|
157
|
+
scigraph workspace remove-paper --root .workspaces --org acme --workspace cardio --paper-id paper-001 --json
|
|
158
|
+
scigraph workspace adjudicate --root .workspaces --org acme --workspace cardio --signature "drugx|fatigue|reaction time|decreases+increases|direct_direction_conflict" --verdict dismiss --actor reviewer-1
|
|
159
|
+
scigraph workspace adjudications --root .workspaces --org acme --workspace cardio
|
|
160
|
+
|
|
161
|
+
# Literature connectors, provenance, batch pipeline & webhook alerts
|
|
162
|
+
scigraph fetch --source arxiv --query "metformin longevity" --output arxiv.json
|
|
163
|
+
scigraph provenance build --store scigraph.db --output manifest.json
|
|
164
|
+
scigraph provenance verify --store scigraph.db --manifest manifest.json
|
|
165
|
+
scigraph pipeline --input path/to/corpus/ --store scigraph.db --report-dir reports/
|
|
166
|
+
scigraph alert --store scigraph.db --json
|
|
167
|
+
|
|
168
|
+
# Local HTTP / OpenAPI 3.1.0 server
|
|
169
|
+
scigraph serve --store scigraph.db --host 127.0.0.1 --port 8765
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### HTTP / OpenAPI Server Endpoints
|
|
173
|
+
|
|
174
|
+
| Method & Path | Description |
|
|
175
|
+
| --- | --- |
|
|
176
|
+
| `GET /` | Interactive HTML Claim-Graph Explorer (WCAG 2.1 AA) |
|
|
177
|
+
| `GET /health`, `HEAD /health` | Liveness and store status check |
|
|
178
|
+
| `GET /metrics` | Server and graph operational metrics |
|
|
179
|
+
| `GET /openapi.json` | OpenAPI 3.1.0 specification |
|
|
180
|
+
| `GET /api/v1/papers` | List papers in the graph (`?paper_id=`, `?include_full_text=`) |
|
|
181
|
+
| `GET /api/v1/claims` | Query verified `ScientificClaim` records |
|
|
182
|
+
| `GET /api/v1/contradictions` | List detected `ContradictionPair` conflicts |
|
|
183
|
+
| `GET /api/v1/consensus` | Compute topic-level directional consensus and claim scores |
|
|
184
|
+
| `GET /api/v1/prioritize` | Rank falsifiable experiment proposals by ROI |
|
|
185
|
+
| `GET /api/v1/audit` | Read workspace audit events |
|
|
186
|
+
| `GET /api/v1/adjudications` | List contradiction adjudication records (reader+) |
|
|
187
|
+
| `POST /api/v1/adjudications` | Create an adjudication (`uphold`/`dismiss`/`split`; adjudicator+ role) |
|
|
188
|
+
| `GET /api/v1/report` | Generate structured contradiction & experiment report |
|
|
189
|
+
| `POST /api/v1/verify` | Verify submitted papers/claims (`?persist=true` with workspace binding) |
|
|
190
|
+
| `DELETE /api/v1/papers/{paper_id}` | Remove a paper and its claims from the bound workspace |
|
|
191
|
+
|
|
192
|
+
### MCP Server (optional extra)
|
|
193
|
+
|
|
194
|
+
SciGraph exposes an [MCP](https://modelcontextprotocol.io) tool surface so agents can call verify/query/report/adjudicate natively. It adapts the same `SciGraphApp` dispatch as the REST server — identical authz and validation — and requires the optional extra:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
pip install 'axiom-scigraph[mcp]' # core install stays stdlib + pydantic only
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
# stdio transport (local agent launch; see auth note below)
|
|
202
|
+
scigraph mcp --store scigraph.db
|
|
203
|
+
|
|
204
|
+
# streamable-http transport (per-call Bearer token required with --tokens)
|
|
205
|
+
scigraph mcp --transport streamable-http --tokens policies.json --host 127.0.0.1 --port 8766 \
|
|
206
|
+
--workspace-root ./workspaces --org acme --workspace main
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Tools: `scigraph_health`, `scigraph_list_claims`, `scigraph_list_papers`, `scigraph_get_paper`, `scigraph_contradictions`, `scigraph_consensus`, `scigraph_prioritize`, `scigraph_report`, `scigraph_adjudications`, `scigraph_audit`, `scigraph_adjudicate` (adjudicator+ role), `scigraph_verify_papers` (ingestor+ role for `persist=true`).
|
|
210
|
+
|
|
211
|
+
**Auth boundary:** stdio carries no per-call `Authorization` — it is a local trust boundary; supply a static token via `--bearer-token`/`--bearer-token-file` or `SCIGRAPH_MCP_BEARER_TOKEN(_FILE)` when `--tokens` policies are configured (otherwise calls fail closed with 401). Streamable HTTP requires a per-call `Authorization: Bearer` header validated against the same token policies; non-loopback binds require `--tokens`. Full threat model: [`docs/adr/011-mcp-surface.md`](docs/adr/011-mcp-surface.md).
|
|
212
|
+
|
|
213
|
+
### Deployment & Security
|
|
214
|
+
|
|
215
|
+
- **Containerization**: Build and run with [`Dockerfile`](Dockerfile) and configure environment variables using [`.env.example`](.env.example).
|
|
216
|
+
- **Security Policy**: See [`SECURITY.md`](SECURITY.md) for vulnerability reporting and hardening guidance.
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## Reproducible Benchmark Metrics
|
|
221
|
+
|
|
222
|
+
Measured on Python 3.12 across the 30-paper benchmark corpus (`src/evals/benchmark.py`), including 5 open-access arXiv and PubMed two-column PDF streams (`src/ingest/open_access_corpus.py`) and 150 adversarial decoy claims containing fabricated DOIs, p-values, sample sizes, and quote spans:
|
|
223
|
+
|
|
224
|
+
| Metric | Target Threshold | Measured Result | Verification |
|
|
225
|
+
| --- | --- | --- | --- |
|
|
226
|
+
| Structured claim-tuple extraction F1 | >= 0.85 | **1.0000** (60 TP, 0 FP, 0 FN) | `test_30_paper_benchmark_exceeds_acceptance_thresholds` |
|
|
227
|
+
| Fabricated DOIs accepted | 0 | **0** (30 / 30 fabricated DOI decoys rejected) | `test_deterministic_verifier_rejects_fabricated_doi_p_value_and_sample_size` |
|
|
228
|
+
| Fabricated p-values accepted | 0 | **0** (120 / 120 fabricated p-value, sample-size, and span decoys rejected) | `test_30_paper_benchmark_exceeds_acceptance_thresholds` |
|
|
229
|
+
| End-to-end 30-paper pipeline latency (median) | Deterministic local run | **3.415 ms** (range 2.793 to 4.120 ms across 7 runs) | Bound by regex tokenization and Pydantic v2 validation on 1 core |
|
|
230
|
+
|
|
231
|
+
Fabricated-DOI rejection works by provenance, not by checking synthesized text against itself: papers carry `doi_provenance` (`parsed` / `connector_metadata` / `fabricated`), the verbatim DOI check runs only on genuinely parsed text, and any DOI in the reserved `10.0000/*` fallback namespace is force-marked `fabricated`. Decoy claims are rejected on claim-vs-paper DOI mismatch regardless of the paper-level check.
|
|
232
|
+
|
|
233
|
+
Regenerate locally and run the full quality gate:
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
.venv/bin/ruff check src tests
|
|
237
|
+
.venv/bin/mypy --strict src tests
|
|
238
|
+
.venv/bin/pytest -v
|
|
239
|
+
PYTHONPATH=src .venv/bin/python -m scigraph.cli benchmark
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Contributing & License
|
|
245
|
+
|
|
246
|
+
- **Contributing**: See [`CONTRIBUTING.md`](CONTRIBUTING.md) for development setup, coding standards (`ruff`, `mypy --strict`, `pytest`), and PR guidelines.
|
|
247
|
+
- **Changelog**: See [`CHANGELOG.md`](CHANGELOG.md) for release history.
|
|
248
|
+
- **Architecture Decision Records**: See [`docs/adr/`](docs/adr/) for design rationale (`001` through `007`).
|
|
249
|
+
- **License**: Released under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "axiom-scigraph"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "SciGraph: Neuro-Symbolic Scientific Discovery & Reasoning Engine"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
authors = [{name = "Justin Mafie"}]
|
|
12
|
+
keywords = [
|
|
13
|
+
"scientific-discovery",
|
|
14
|
+
"neuro-symbolic",
|
|
15
|
+
"claim-graph",
|
|
16
|
+
"contradiction-detection",
|
|
17
|
+
"sarif",
|
|
18
|
+
"cli",
|
|
19
|
+
"reproducibility",
|
|
20
|
+
]
|
|
21
|
+
classifiers = [
|
|
22
|
+
"License :: OSI Approved :: MIT License",
|
|
23
|
+
"Operating System :: OS Independent",
|
|
24
|
+
"Programming Language :: Python :: 3",
|
|
25
|
+
"Programming Language :: Python :: 3.12",
|
|
26
|
+
"Topic :: Scientific/Engineering",
|
|
27
|
+
]
|
|
28
|
+
requires-python = ">=3.12"
|
|
29
|
+
# PyPI distribution name decided in TODO-1: `axiom-scigraph` (the `scigraph`
|
|
30
|
+
# name was avoided to prevent confusion with Springer Nature's SciGraph
|
|
31
|
+
# knowledge-graph product). The `scigraph` console script below is unchanged.
|
|
32
|
+
dependencies = [
|
|
33
|
+
"pydantic>=2.9",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[project.urls]
|
|
37
|
+
Repository = "https://github.com/creova-gif/scigraph"
|
|
38
|
+
Homepage = "https://github.com/creova-gif/scigraph"
|
|
39
|
+
|
|
40
|
+
[project.scripts]
|
|
41
|
+
scigraph = "scigraph.cli:main"
|
|
42
|
+
|
|
43
|
+
[project.optional-dependencies]
|
|
44
|
+
dev = [
|
|
45
|
+
"pytest>=8.0",
|
|
46
|
+
"mypy>=1.10",
|
|
47
|
+
"ruff>=0.6",
|
|
48
|
+
]
|
|
49
|
+
# EXP-F: MCP server surface (modelcontextprotocol/python-sdk). Core stays
|
|
50
|
+
# stdlib+pydantic only; `scigraph mcp` raises an ImportError naming this extra
|
|
51
|
+
# when it is not installed. Pin tracks the 2025-11-25/2026-07-28 era SDK.
|
|
52
|
+
mcp = [
|
|
53
|
+
"mcp>=2.3,<3",
|
|
54
|
+
]
|
|
55
|
+
# EXP-A (D10): LLM claim-extraction providers. The ClaimExtractor interface,
|
|
56
|
+
# fixture/local providers, span resolution, and the verbatim gate are
|
|
57
|
+
# stdlib+pydantic only; the concrete OpenAICompatExtractor lazily imports the
|
|
58
|
+
# `openai` SDK and raises an ImportError naming this extra when absent. A
|
|
59
|
+
# loopback base_url (Ollama/LM Studio) counts as `local` egress — no
|
|
60
|
+
# workspace opt-in needed; anything else is `external` and fail-closed.
|
|
61
|
+
llm = [
|
|
62
|
+
"openai>=1.50,<2",
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
[tool.setuptools.packages.find]
|
|
66
|
+
where = ["src"]
|
|
67
|
+
|
|
68
|
+
[tool.pytest.ini_options]
|
|
69
|
+
pythonpath = ["src"]
|
|
70
|
+
testpaths = ["tests"]
|
|
71
|
+
|
|
72
|
+
[tool.mypy]
|
|
73
|
+
strict = true
|
|
74
|
+
mypy_path = "src"
|
|
75
|
+
packages = ["scigraph", "ingest", "graph", "solver", "evals"]
|
|
76
|
+
|
|
77
|
+
[tool.ruff]
|
|
78
|
+
line-length = 100
|
|
79
|
+
target-version = "py312"
|
|
80
|
+
|
|
81
|
+
[tool.ruff.lint]
|
|
82
|
+
select = ["E", "F", "I", "UP", "B"]
|