Metadata-Version: 2.4
Name: glimmer-rokb
Version: 0.7.1
Summary: Research-object knowledge base: schema validation, live graph querying, retrieval, provenance sync, and executable verification
Author-email: Shady El Damaty <se394@georgetown.edu>
License-Expression: MIT
Project-URL: Homepage, https://glimmer.science
Project-URL: Repository, https://github.com/hebbianloop/glimmer
Project-URL: Issues, https://github.com/hebbianloop/glimmer/issues
Project-URL: Documentation, https://github.com/hebbianloop/glimmer/blob/main/README.md
Project-URL: Changelog, https://github.com/hebbianloop/glimmer/blob/main/CHANGELOG.md
Keywords: research-objects,knowledge-graph,provenance,reproducibility,ai-for-science,neuroimaging,datalad,ro-kb
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: PyYAML>=6.0
Provides-Extra: imaging
Requires-Dist: nibabel>=5; extra == "imaging"
Provides-Extra: figures
Requires-Dist: numpy>=1.24; extra == "figures"
Requires-Dist: matplotlib>=3.7; extra == "figures"
Requires-Dist: networkx>=3; extra == "figures"
Dynamic: license-file

# Glimmer

> **An AI-native solution to the reproducibility problem.**
>
> The 2010s gave us reproducible pipelines. Glimmer is the next layer up — a typed-entity graph over those pipelines whose runs are **executable, standard-gated, and self-verifying**, so "this result reproduces" is a claim checked against recorded evidence, not a footnote you trust.

[![Status: v0.7.0](https://img.shields.io/badge/status-v0.7.0-blue.svg)](https://github.com/hebbianloop/glimmer)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
[![Template](https://img.shields.io/badge/repo-template-purple.svg)](https://github.com/hebbianloop/glimmer/generate)

## What this is

Existing standards (BIDS, DataLad, NIDM, Nipype) give your project syntactic structure. Glimmer adds the **graph layer**: datasets, methods, derivatives, findings, concepts, standards, publications, and external references become first-class typed nodes with versioned edges, distributed across per-entity sidecars. An AI agent or researcher navigates, searches, syncs, and verifies the graph with zero database or ML dependencies.

**Everyday querying, sync, retrieval & Agent Skill (v0.7.0).**
- **Live query & retrieval CLI (`glimmer summary`, `query`, `neighbors`, `search`)**: metadata-only by default (`--no-body`) so star hubs never overflow context, plus a stdlib-only Okapi `Bm25Retriever` shipped directly in `glimmer/tools/retrieval.py`. Works over live Markdown RO-KBs and compiled `graph.json` workspace editions (`--graph`).
- **Rich, self-navigable `_glimmer-index.json`**: backwards-compatible superset of `{id, type, path}` adding `name`, `status`, `subtype`, `claim-kind`, `role`, `modified`, `provenance-hash`, 1-line `summary`, compact `edges`, and optional `root-node` / `entrypoints`.
- **Clean external literature vs. project outputs**: new core `reference` node type for cited prior work + backwards-compatible `role: external-reference | project-output` on `publication` + epistemic stance edges (`supports`, `challenges`, `contradicts`, `overlaps-with`, `extends`, `superseded-by`, `cites-concept`).
- **Low-friction bootstrap, sync & drift checks**: `glimmer init`, `glimmer sync`, `glimmer status` (detects hash, index, validation, and sibling draft/artifact drift), `glimmer hash`, `glimmer amend`, and `glimmer migrate-references`.
- **Installable Agent Skill (`skills/glimmer/`)**: install into `.agents/skills/glimmer`, `.claude/skills/glimmer`, or `.codex/skills/glimmer` via `glimmer install-skill` (or standard `skills` installers).

**Executable provenance (v0.6).** `glimmer run` checks input content pins and available standard validators before executing a run-record. `glimmer rerun` distinguishes raw byte identity, normalized-content matching, numeric agreement and structural evidence checks. Host execution requires explicit opt-in; structural checks do not certify scientific interpretation. Start with [`docs/proactive-provenance.md`](docs/proactive-provenance.md) and the [portable synthetic fixture](examples/synthetic-provenance/).

The [container qualification example](examples/container-provenance/) exercises
the installed CLI with real DataLad, git-annex, and Docker in a disposable Linux
environment. It retains separate execution, replay, and failure receipts for one
synthetic method; hosted execution and provider authentication remain separate.

Glimmer is domain-agnostic. The canonical worked example in this repo is neuroimaging because that's where standards like BIDS and tools like DataLad and Nipype are most developed — but the architectural pattern (typed-entity graph over a versioned-data substrate) applies to any compute-intensive scientific domain backed by a mature standards ecosystem.

Glimmer is the architectural pattern + a reference implementation. The original architectural argument is in the unpublished CAISC submission (see [`docs/paper-citation.md`](docs/paper-citation.md)).

## How to use this repo

### If you're building a project on top of Glimmer

**Fork or use-as-template** (the green button on GitHub). Then:

1. Keep the `glimmer/` directory unchanged — that's the core schema + tooling.
2. Replace `examples/ds000114-nipype/` with your own project data and sidecars (or keep it as reference).
3. Pin the Glimmer core version in your project's `glimmer-version` file.
4. Do your project work in your fork. **Don't modify `glimmer/` in your fork** unless you intend to send a PR back here.

### If you have an improvement to the Glimmer core

**Open a PR against this repo.** Core changes go through review here so every downstream fork can pick them up cleanly:

- Schema additions or edge taxonomy changes → PR to `glimmer/schema/`
- Bug fixes or new utilities → PR to `glimmer/tools/`
- New documentation or examples → PR to `docs/` or `examples/`

The line between "core" and "project" is the `glimmer/` directory. Anything inside is core; anything outside is your project. The maintainer's job is to keep `glimmer/` stable, small, and self-contained.

## Repo layout

```
glimmer/
├── schema/
│   ├── schema.md            # v0.7 spec — 14 entity types (incl. reference + run-record), edge taxonomy, enriched index
│   ├── frontmatter.yaml     # machine-readable contract for validators
│   └── glimmer-version      # current core version (0.7.0)
└── tools/
    ├── validate.py          # schema validator (core + domain profiles + agent protocol)
    ├── query.py             # `glimmer summary` / `query` / `neighbors` / `search` (live RO-KB & --graph)
    ├── retrieval.py         # LiteratureRetriever Protocol + stdlib Bm25Retriever & NullRetriever
    ├── sync.py              # `glimmer init` / `sync` / `status` / `hash` / `amend` / `migrate-references`
    ├── skill_installer.py   # `glimmer install-skill`
    ├── run.py               # node runner — `glimmer run` / `glimmer rerun` (gate → replay → verify)
    ├── cli.py               # `glimmer` CLI single entry point
    └── figure_schema.py     # render the schema diagram

skills/
└── glimmer/                 # installable cross-agent skill (SKILL.md, references/, agents/, scripts/)

examples/
├── synthetic-provenance/    # v0.6 proactive-provenance demo: loop + 3 tiers + gate + equivalence
└── ds000114-nipype/         # canonical worked example from the CAISC 2026 paper
    ├── install.sh           # `datalad install ///openneuro/ds000114` + selective `datalad get`
    ├── workflow.py          # Nipype anatomical preprocessing (BET → FAST)
    ├── emit_graph.py        # walk the workflow's provenance + emit Glimmer sidecars
    ├── verify.py            # re-run the cited methods + confirm output hashes match
    └── rokb/                # generated Glimmer instance after running the steps above

docs/
├── paper-citation.md        # how to cite Glimmer + the CAISC 2026 paper
├── design-rationale.md      # why typed-entity sidecars over a central database
├── extending-the-schema.md  # process for proposing new node/edge types
├── agent-protocol.md        # the verifiability contract for agent-produced outputs
├── agentic-loop.md          # plans-as-issues + autoresearch over a Glimmer graph
├── datalad-pattern.md       # DataLad as the I/O backbone (mrinit's pattern, generalized)
├── interop.md               # cross-reading BIDS / NIDM / RO-Crate / JSON-LD / schema.org
├── roadmap.md               # v0.3+ entity types (persona, concept, experiment, meta-analysis)
└── faq.md
```

## Quick start

```bash
python -m venv .venv
. .venv/bin/activate
pip install .
python examples/synthetic-provenance/smoke.py
python -m unittest discover -s tests -v
```

This builds the complete synthetic graph from committed sources and exercises the
installed `glimmer` command. The fixture is scripted and runs on the host; it does
not establish an LLM evaluation or container-runtime acceptance. Optional imaging
normalization tests use `pip install '.[imaging]'`.

The [canonical ds000114 example](examples/ds000114-nipype/) remains available for
the neuroimaging workflow and requires DataLad, Nipype and FSL. Its legacy
`verify.py` checks hashes of existing files; a new workflow run is a separate step.

## Core principles

1. **Distributed-over-files, not centralized.** Glimmer graphs survive `git clone`, `datalad export`, `rsync` without bespoke serialization.
2. **Typed entities, not flat documents.** Different entity types invite different agent reasoning strategies.
3. **Edges are first-class.** Every relationship a researcher would name out loud should be an edge in the graph.
4. **Standards are nodes, not background.** BIDS spec versions, FreeSurfer releases, atlas versions are addressable, not implicit.
5. **Provenance is intrinsic.** Every node carries a content hash; every edge carries a version. Re-running a workflow from the graph's pinned SHAs is the verifiability test.
6. **Source-first sanity check.** When a verification fails or a pipeline goes sideways, rebuilding the method from upstream source is often the recovery move. The schema makes this expressible (`source-checkout-url`, `source-build-instructions`) and the verifier can fall back to a source-rebuild rather than trusting a cached binary that may have drifted.

## Versioning policy

Glimmer follows semantic versioning at the **schema** level. Core utility updates that don't change the schema are minor; schema changes that break existing sidecars are major. The current schema version is recorded in `glimmer/schema/glimmer-version`.

v0.3.1 added the meta-graph social layer: the `persona` and `organization` node types and the in-graph attribution edges (`authored-by`, `affiliated-with`, `funded-by`, `mentors`, `leads`, `part-of`).

v0.3 added the `experiment` node type (active task/acquisition paradigms), the `concept` node type (the research-question / hypothesis layer a program operates at), and the universal `contributed-by` attribution edge.

v0.2 dropped `qc-artifact` and `rater` (over-indexed on QC as the canonical example) and added `finding` (EVI-aligned) between `derivative` and `publication`. Agent identity is now a string field on `finding` and `derivative` rather than a separate node type.

## Citation

If you use Glimmer in your research, cite:

> El Damaty, S. (2026). *Reproducibility as Knowledge Graph Navigation: Glimmer, a Research-Object Knowledge Base for AI-Native Neuroimaging Analysis.* Unpublished manuscript, 2026.

See [`docs/paper-citation.md`](docs/paper-citation.md) for the BibTeX entry.

## License

MIT.
