Synirmos
Build temporal knowledge graphs from source evidence.
Synirmos is a Python framework for ontology-driven knowledge graph construction and graph-guided retrieval. It stores claims and their supporting evidence in a temporal labeled property graph backed by GestaltDB. It distinguishes when a claim was valid from when its evidence was available, so a historical query does not silently use information learned later.
Build a graph from your sources
- Capture and parse. Supply UTF-8 plain text or Markdown as text, bytes, or explicitly selected files. Parsing and chunking preserve references to the original bytes and require no repository, graph database, or model.
- Define the ontology and review proposals. The ontology describes the entities and relationships the application accepts; it does not control syntax parsing. The opt-in JERE provider can propose entities and relations from text using an injected chat model. Validate proposals against the schema and source bytes, then review them before publishing. Published claims retain their evidence and review provenance.
- Retrieve cited context. The reference retriever uses lexical matching to find starting points, then follows ontology-selected relationships within the same pinned graph view and returns supporting source quotes.
The pipeline is source-neutral, not a universal importer. PDFs, APIs, databases, and event streams need adapters that preserve source identity, evidence, access scope, and observation time. Text-producing adapters can feed the document pipeline; structured records can be mapped to graph writes under a trusted policy without turning them into prose for a model.
Start with the JERE-to-KG notebook to propose, review, and publish a fact, or the cited retrieval walkthrough to see historical replay and a policy change. Both run offline with fixtures; they do not demonstrate real-model accuracy or production-scale retrieval. See the documentation index for more examples.
Repository and SDLC specialization
The repository pipeline analyzes Git history, source code, documentation, and
GitHub issues and pull requests. It reads captured blobs, parses Python and
Markdown without executing target code, and links commits, files, topics, and
work items with evidence. Use the repository setup
or the tf_gnns example to produce an inspection
report and SVG. The inspection workflow can run without a graph database and
does not invoke JERE by default. The shared writer is available for temporal
persistence.
See the project specification for architecture and guarantees, and the decoupling epic for open work.
Development
git clone git@github.com:mylonasc/synirmos.git
cd synirmos
uv sync --locked --dev
uv run pytest
Synirmos is a packaged uv project with a committed uv.lock and a Python 3.11
development default in .python-version. Python 3.11–3.13 are supported.
To use it from another uv project:
uv add "synirmos @ git+https://github.com/mylonasc/synirmos.git"
Importing the package does not require provider credentials. Live GitHub and LLM runs are opt-in. The default test suite needs no secrets or network access.
Build the wheel and source distribution using uv's native backend and standard
src/synirmos/ layout:
uv build
Artifacts are written to dist/. No package-name overrides or extra build
scripts are needed. See CHANGELOG.md for changes and import
migration notes.
Local quality checks and CI
uv run python scripts/check.py # all checks used by CI and pre-push
uv run ruff check . # lint, imports, Python modernization, complexity
uv run ruff format --check . # formatting (omit --check to format)
uv run pytest --cov=synirmos --cov-report=html
uv run python scripts/metrics.py # complexity, maintainability, source size
uv run pre-commit install # install pre-commit and pre-push hooks
Every push and pull request runs the full checks on Python 3.11, 3.12, and 3.13 via GitHub Actions. Lint and formatting must pass, combined statement/branch coverage must remain at least 90%, and function cyclomatic complexity is capped at 30 (the initial ceiling for existing code, not a target for new functions). CI also builds the distribution, smoke-tests an installed wheel outside the source tree, and runs the example's separate offline regression test. Live GitHub/LLM runs are never part of CI.
Reports are generated under reports/: coverage XML/HTML, per-module
maintainability and complexity JSON, and a Markdown summary. CI uploads these
as artifacts and publishes the metrics summary. Hooks run lint/format checks
before commits and the full quality suite before pushes; install them once per
clone. All checks are also available manually without hooks.
PyPI releases
Increasing project.version on main triggers
publish-pypi.yml. It reruns the Python
quality matrix, builds and validates the distributions, then publishes using
PyPI trusted publishing (OIDC, no API-token secret). Unchanged versions are not
published. See publishing instructions for version bumps,
lockfile updates, retries, and trusted-publisher configuration.
Package structure
The detailed refactoring plan describes the next
steps toward remote-authoritative Git captures, interchangeable GitHub/GitLab
integrations, future Jira issues, and independent language-parser plugins.
Initial platform contracts live in platform_integrations/; the existing
GitHub pipeline has not yet been migrated to them.
src/synirmos/
core/ # domain contracts, configuration, IDs, events, budgets, protocols
sources/ # explicit document capture/projections, Git and GitHub adapters
parsing/ # shared pure document parsing and deterministic chunking
context/ # empty/in-memory/graph-backed scoped selection
extraction/ # neutral schema/profile/validation seam and explicit test fakes
staging/ # durable candidates, gaps and guarded reviews
resolution/ # qualified identities and reviewed reversible merges
retrieval/ # ontology-guided traversal and cited context
processing/ # repository content, ontology, topics, enrichment and linking
storage/ # GestaltDB persistence and backend capability checks
runtime/ # journal/replay orchestration and worker processes
reporting/ # inspection queries, SVG rendering, evaluation metrics
Implementations and imports use these domain packages directly, such as
synirmos.sources.git and synirmos.processing.repository.content. There is no separate
legacy namespace or flat compatibility layer to package. Boundary tests prevent
example dependencies or provider imports from entering core.
Analyze your own repository
The library accepts a repository URL, a full commit SHA, a UTC time window, and
an explicit work-item allowlist. Start with the generic
configs/repository.toml template; the library has
no built-in repository selection or implicit configuration path.
Copy that configuration to your own TOML file and set:
repository.owner,name, andurlto your target repository.repository.anchorto a full 40-character commit SHA.repository.window.startandendto your UTC interval (start inclusive, end exclusive).repository.allowed_work_itemsto the issue/PR numbers to fetch, or[]for no GitHub work-item discovery.- Budgets, cache paths, and graph settings for your workload.
For local Git and content analysis, use an existing checkout containing the anchor and required ancestry:
from synirmos import load_config
from synirmos.processing.repository.content import ContentExtractor
from synirmos.sources.git import GitHistory
config = load_config("my-repository.toml")
history = GitHistory.open("/path/to/checkout", repository_url=config.repository.url)
try:
selection = history.select(
config.repository.anchor,
config.repository.window,
max_depth=config.git.max_depth,
)
if len(selection.selected_commits) > config.budgets.max_commits:
raise ValueError("selected history exceeds the configured commit budget")
index = history.index(selection)
content = ContentExtractor.from_history(history).extract(index)
print(f"{len(index.selection.selected_commits)} commits, {len(content.snapshots)} snapshots")
finally:
history.close()
This path makes no GitHub or LLM calls and opens no graph database. Missing
ancestry and unsupported content are reported as coverage gaps. Always pass
your configuration explicitly to load_config(path); calling it without a
path is an error. Paths in the configuration are relative to the working
directory of the calling application.
Reproducible sample
The self-contained examples/tf_gnns/ workflow
owns its configuration, scripts, recorded evidence, tests, and historical
artifacts. It consumes the installed library without changing sys.path.
Neither the library, its generic tests, nor its wheel/source distributions
depend on that example. See the example README for setup and run commands.
Setup and privacy
Setup is local-first: the default test suite and the recorded-evidence fixtures need no secrets and no network. Remote access is explicit:
- Git clone/fetch operations access the configured remote when explicitly called; opening and analyzing an existing local checkout does not fetch history.
- GitHub access reads the configured repository and allowlisted work items through
httpx(GITHUB_TOKENfrom the configuredtoken_env; unauthenticated runs also work within rate limits). Raw responses are cached underdata/cachewithout credentials; the token is used only for authentication and is not persisted in evidence files. - LLM enrichment requires
llm.enabled = trueandllm.privacy_consent = true, plus theopenaiextra (uv run --with langchain-openai ...) andOPENAI_API_KEY. Prompts carry only repository evidence already selected for indexing, and every call is budgeted, cached, and recorded with model/prompt/schema provenance.
The analysis does not execute target-repository code or mutate remote work
items. Git clone/fetch writes to the local checkout or object cache; unavailable
source history is reported as explicit coverage gaps, never invented.
examples/tf_gnns/evaluate.py reproduces the bounded live evaluation; pass --llm only
with consent and a key.
Content extraction
ContentExtractor reads blobs through the Git index instead of the working
tree, so baseline snapshots describe the historical commit rather than HEAD:
from synirmos.processing.repository.content import ContentExtractor
index = history.index(selection)
extractor = ContentExtractor.from_history(history)
content_index = extractor.extract(index)
Parsing is keyed by (blob oid, media type), so identical bytes are parsed once
while every snapshot keeps its own snapshot_id, commit, path, and source URL.
Markdown headings, links, fenced code blocks, and sections carry character
offsets and line ranges into the original blob; Python files are inspected with
ast only and are never imported or executed.
Statuses are explicit: parsed, empty, unsupported (binary or Git LFS
pointer), oversized, undecodable, gitlink, and unavailable. Each
non-parsed status emits a CoverageGap, as do truncated section, symbol, and
import lists, so configured limits stay observable in the output.
GitHub work items and evidence
GitHubDiscoverer reads only the work items named by
repository.allowed_work_items and keeps every raw response it used:
from synirmos.sources.github import (
EvidenceCache,
GitHubCredentials,
GitHubDiscoverer,
)
discovery = GitHubDiscoverer(
config.repository,
config.github,
cache=EvidenceCache(config.cache_dir),
credentials=GitHubCredentials.from_env(config.github),
).run()
Responses are stored with fetch metadata (URL, status, hashes, ETag,
Last-Modified, rate-limit headers, and the next pagination link), keyed by a hash
of the canonical request URL. Re-runs send conditional requests, and an offline
run replays saved evidence without opening a socket. Missing evidence, denied
optional endpoints, exhausted budgets, and pagination truncation become explicit
CoverageGaps or AbsenceRecords instead of silently empty results.
A parent lookup that was a 404 online leaves no cache entry, so offline replay treats the missing entry the same way: no parent edge, no gap. Online and offline runs therefore agree on events and coverage.
Current issue bodies, labels, and comments are observations stamped at fetch
time; they are never backdated to the item's creation. Creation, comments, and
timeline events keep their source timestamps, while RevisionAvailability
records that GitHub REST does not expose earlier body/label revisions. Labels,
native parent/sub-issue edges, PR heads, bases, merge commits, and PR commit
lists are captured when present, and out-of-scope hierarchy edges are flagged
without fetching the external item. Credentials are read from the configured
environment variable and are never written to the cache.
Temporal replay and resumable orchestration
TemporalCoordinator merges Git and GitHub event streams into one
deterministic history: stable ordering by (event_time, source, source_id, sequence), causal conflict resolution (later observations correct earlier
ones; exact ties break deterministically), and deferral of events whose
dependencies have not arrived yet. git_selection_events turns a bounded
GitSelection into BASELINE events for boundary commits and COMMIT events
for selected commits; immutable commits carry info_horizon == event_time,
while mutable remote observations carry info_horizon == observed_at.
from synirmos.runtime.orchestration import (
EventJournal,
StageRunner,
TemporalCoordinator,
git_selection_events,
)
runner = StageRunner.resume_or_create(
config.orchestration.journal_file,
config.orchestration.checkpoint_file,
manifest,
config.budgets,
)
snapshot = runner.run_stage("git", lambda: (git_events, git_gaps))
result = TemporalCoordinator(config.repository).collect(snapshot.events)
usable = TemporalCoordinator.visible_at(result.effective, horizon)
EventJournal persists events and gaps as an append-only JSONL log with a
manifest header (run, repository, config fingerprint); byte-identical
duplicates are skipped and corrections are kept. CheckpointStore records
completed stages with the budget ledger counters and a digest binding the
checkpoint to the journal prefix, so retries and resumes continue spending the
same budgets and a diverged journal fails closed. bootstrap splits
per-boundary bootstrap state from in-window replay, and visible_at gates
enrichment by information horizon so future labels, docs, or async results
cannot seed past decisions. Unavailable history stays a retryable gap; nothing
is invented for it.
GestaltDB temporal graph persistence
GestaltGraphStore owns the database handle; its borrowed neutral writer checks
an explicit profile and trusted write policy, preserving source times/evidence
and atomically publishing bounded history/current batches on LMDB:
from synirmos.core.graph import GraphWriteBatch
from synirmos.storage.backends.gestaltdb import GestaltGraphStore
from synirmos.storage.batches import iter_write_batches
from synirmos.storage.mappings.repository import RepositoryMapper
from synirmos.storage.repository import NODE_INDEXES, EDGE_INDEXES
mapper = RepositoryMapper(ids) # proposed by default, not publication approval
with GestaltGraphStore.create(config.graph, run_id=run_id,
node_indexes=NODE_INDEXES, edge_indexes=EDGE_INDEXES) as store:
writer = store.writer(profile=mapper.profile, policy=trusted_policy)
for value in iter_write_batches(
mapper.git(index, captured_at=captured_at),
context=mapper.context(run_id=run_id, capture_id=capture_id),
payload_size=writer.encoded_payload_bytes,
):
if isinstance(value, GraphWriteBatch):
writer.write(value)
else:
gaps.append(value) # missing endpoints stay explicit
RepositoryMapper.git emits Commit, Snapshot, File, and Branch entities with
PARENT_COMMIT, MEMBER_OF, OF_FILE, and TIP_OF relationships;
RepositoryMapper.github emits WorkItem and ProviderLabel entities with HAS_LABEL,
CHILD_OF, and MERGED_AS relationships. Out-of-scope parents and hierarchy
edges produce explicit gaps, never invented endpoints. Standalone documents use
the same writer with their own profile; no repository configuration is required.
Version UUIDs derive from global intent keys. Exact replay adds no commits and
cannot rewind newer projections; conflicting reuse fails. Corrections/retractions
use explicit VersionIntent values. Reads never repair indexes: the writer calls
prepare_reads() when necessary. Convenience valid-time/current reads are not
authorized scoped context readers (D3). See storage migration notes
and the executable D1 notebook
for policy issuance, source clocks, bounds and breaking API/store-format decisions.
Topic registry and deterministic labeling
DeterministicLabeler assigns topics without a model: deterministic
path/language/heading/reference features describe each subject, a classical
TF-IDF baseline retrieves candidate topics by cosine similarity, and the
outcome is reuse, a genuinely new proposal, an alias suggestion, or an
explicit abstention — each with matched terms as the rationale:
from synirmos.processing.labeling import (
DeterministicLabeler,
extract_snapshot_features,
seed_registry,
)
labeler = DeterministicLabeler(config.labeling)
registry = seed_registry(at=now)
assignment = labeler.assign(
features, registry, subject_id=subject_id,
run_id=run_id, info_horizon=horizon,
)
Provider labels are preserved verbatim by preserve_provider_labels in a
separate assignment namespace; derived topics never absorb them silently.
Assignments are AnalysisResult envelopes, so each decision key already binds
subject, method, horizon, and evidence. Growing the registry (registrations,
aliases, merges) never rewrites old assignments: they reference the registry
version they were decided against, merges mark old topics as superseded
instead of deleting them, and re-running against a kept registry snapshot
reproduces the original decisions exactly. LabelingSettings ([labeling]
section) sets the reuse/alias thresholds, minimum score, and retrieval limit.
LangChain structured LLM enrichment
Use the OpenAI or Ollama wrappers and local LanceDB search for reusable model construction and hybrid candidate retrieval.
Enricher wraps an injected LangChain chat model (BaseChatModel) with
opt-in consent, budgets, caching, validation, and full provenance. Proposals
are typed (LLMTopicProposal, LLMSummaryProposal, LLMLinkProposal) and
grounded: reused topics and link targets must come from the supplied
candidates, and invalid output is retried, then abstained — never invented:
from synirmos.processing.enrichment import Enricher, EnrichmentCache, build_chat_model
settings.llm.enabled = True # plus privacy_consent=True, or it refuses
model = build_chat_model(settings.llm) # selects the configured OpenAI or Ollama provider
enricher = Enricher(
model, settings.llm, ledger=ledger,
cache=EnrichmentCache(settings.llm.cache_file), run_id=run_id,
)
result = enricher.enrich_topic(
subject_id=..., subject_text=..., candidates=[...],
registry_version=..., info_horizon=...,
)
Every call reserves LLM requests/tokens from the shared BudgetLedger
before invoking (retries spend too), records estimated and actual usage in
Provenance, and caches the validated proposal under a key of model, prompt
version, schema version, method, and context hash — changing any of them
invalidates the entry. Tests use GenericFakeChatModel from
langchain-core; the real smoke runs ChatOpenAI (gpt-4.1-mini) via the
openai extra with explicit consent. Unavailable history becomes a
llm-history-unavailable gap instead of a prompt. [llm] settings cover
provider, model, temperature, privacy consent, retry attempts, prompt version,
and cache file.
Separate worker processes
WorkerPool runs work-item analysis in spawned OS processes. Jobs are
durable, versioned envelopes with fully embedded inputs (feature snapshot,
candidates, registry snapshot, horizon), so any worker — now or after a
restart — replays the same job:
from synirmos.runtime.worker import JobQueue, WorkerPool, collect_results, make_job_id
queue = JobQueue("data/work")
queue.submit(WorkJob(job_id=make_job_id(...), ...)) # resubmits dedupe
pool = WorkerPool(queue, max_workers=2, task_timeout_seconds=120.0)
pool.run_pending() # crashed/timed-out jobs stay resumable
results = collect_results(queue) # merged in (horizon, job_id) order
Required enrichment (deterministic labeling) must succeed for a job to
complete; optional enrichment (LLM proposals, rebuilt from embedded settings
and scripted replies) may abstain or fail while the job still completes, and
the two outcomes stay distinguishable in WorkResult. Results echo the job's
horizon and record the worker PID; merging sorts by horizon so out-of-order
completion cannot publish future context into an earlier event. Repeats are
byte-identical by job_id, and the coordinator charges the shared ledger only
for accepted optional usage.
Evidence-backed cross-entity linking
processing/linking.py defines domain-neutral link values and exact triple
scoring with arbitrary predicate IDs. The specialization
processing/repository/linking.py resolves textual references (#123, owner/repo#123, issue/PR
URLs, commit SHAs, known file paths) and provider relationships (merged PRs,
head/base branches) against known entities only. Unresolved numbers, foreign
repositories, unknown or ambiguous SHAs, and deleted branches are reported as
references, never invented into links:
from synirmos.processing.repository.linking import (
infer_topical_links,
resolve_provider_links,
resolve_textual_links,
)
text_report = resolve_textual_links(texts, ids=ids, ...)
provider_report = resolve_provider_links(discovery, index, ids=ids, ...)
topic_report = infer_topical_links(item_topics, file_topics, ids=ids, ...)
Default repository relations stay distinct: MENTIONS (textual reference), INTENDS_TO_RESOLVE
(fix/close/resolve intent, never inferred from Merge pull request lines),
CLOSED_BY (provider closure: merged PR to merge commit, with squash
evidence as merge_style: non-head and no invented ancestry), and
RELATED_TO (scored inference: shared derived topics, branch association).
Weak topical overlap abstains with its score instead of linking.
LinkRecord.to_result() wraps each link as an analysis envelope (not write
approval), and RepositoryMapper.links() maps it to neutral write intents.
All repository entry points accept RepositoryLinkVocabulary; custom predicate
IDs must also be declared in repository_profile(link_predicates=...).
Neutral score_links() measures precision/recall over annotated fixtures.
LinkingSettings ([linking] section) sets the inference score floor.
Inspection queries and visualization
The repository-specialized Inspector answers six questions from adapter outputs —
no database, no network — with horizon and coverage attached to every
answer: commit-range changes, work-item traces with evidence, branch
containment, topic timelines (emergence then recurrence), files and sections
for a work item at a chosen time, and attribution for labels and links:
from synirmos.reporting.repository.inspection import Inspector
inspector = Inspector(
index=index, discovery=discovery, content=content, links=links,
assignments=assignments, info_horizon=horizon, run_id=run_id,
repository_url=repo_url,
)
changes = inspector.changes_in_range(from_sha, to_sha)
traces = inspector.work_items_for_commits([sha, ...])
timeline = inspector.topic_timeline(topic_id)
The reference runbook executes the analysis on
its recorded slice and saves report.md plus slice.svg in its output directory. The figure
is deterministic SVG (stdlib only): factual links are solid blue, inferred
topical links are dashed amber, nodes are capped at a fixed budget with
omissions reported, and the footer records run, horizon, counts, and gaps.
viz.render_slice_svg() renders any bounded slice the same way.
Metadata
Release files for synirmos 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| synirmos-0.2.1.tar.gz | 665.3 kB | With provenance | Details for synirmos-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| synirmos-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for synirmos-0.2.1-py3-none-any.whl |
Total release size: 929.5 kB
Release files / synirmos-0.2.1.tar.gz
| Download URL | synirmos-0.2.1.tar.gz |
|---|---|
| Size | 665.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9cb627647d75f108c35eae982c52f299415f5d0be62052ff8c462d44fe9f9725
|
|
BLAKE2b-256 checksum How to use checksums |
c3f98e937dfe061a5f3a58320b7385c67ce7111c02e26a62f8a35f71e372024e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logRelease files / synirmos-0.2.1-py3-none-any.whl
| Download URL | synirmos-0.2.1-py3-none-any.whl |
|---|---|
| Size | 264.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7976d736a404408758524426dc6b8ef61e7a7befe22edd9678cd963e35b7aa05
|
|
BLAKE2b-256 checksum How to use checksums |
e0061da76032460e2bdf20b1e166864d3e6f9ba2191cd0fe317a6ae28a8b8d32
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logSecurity for synirmos 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for synirmos-0.2.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.