mjdi

Search documentation

Search the mjdi v0.10.0 documentation

Documentation

v0.10.0latest

Served live from mjdi/docs/ — the same markdown ships to agents via /api/mcp.

Welcome to the documentation for mjdi, the compile-time-first dependency injection library for Mojo 1.2.0. Every document in this set describes the implemented, tested behavior of the library — not a design target. Claims about compiler behavior are backed by experiments in experiments/ and cataloged in technical-investigation.md.

The release these documents describe: mjdi 0.10.0 against mojo 1.2.0 (2016d0cd). See changelog.md for the release history.

The documentation map

Start here

DocumentWhat it covers
Getting startedInstalling Mojo, getting mjdi, your first wired application, running the examples and the test suite.
TutorialBuild a complete application step by step — every provider kind, every lifetime, with verified output at each stage.
Core conceptsThe vocabulary and the mental model: services, providers, scopes, registries, containers, and the compile-time/runtime split.

Everyday use

DocumentWhat it covers
Usage guideThe concise practical guide: declaring services, all four provider kinds, scopes, custom construction, the error model.
ProvidersDeep dive on class, value, factory, and alias providers — semantics, constraints, selection guide.
Third-party typesThe use_* family: wiring structs you do not own (use_value, use_provider) with every lifetime.
Scopes and lifetimesTransient, singleton, and scoped behavior in full: caching, copies, create_scope(), close_scope().
Dependency declarationInject[T] in depth: value(), is_resolved(), cloned(), nested graphs, and the immutable-reference rule.
Linear services@__annotation(mjdi_linear) linear types: construct-in-place, single use through the resolve[T](/docs/0.10.0/visitor) overload, explicit destroy, and the trait-bound/where-clause overloads that keep linear values out of caching lifetimes.
Linear resource patternsTransactions, file leases, lock tokens: the resource-oriented linear patterns with the destruction-diagnostics matrix (P1-21/P1-22).
InjectableThe Injectable contract: two-phase construction, requirements, and overriding create().
Lifecycle hooksThe InjectableLifecycle contract: post_construct after wiring, pre_destruct before mjdi releases a cached instance (close() / close_scope()), and the deliberate exclusions.
Runtime validationThe value-provider inventory, missing_values, and validate_runtime() — startup checks that never construct a service or run a factory (P1-06/P1-07).
Registry overridesThe override / override_value / override_factory family: typed test composition by replacing providers (P1-09).
Scope guardwith_scope and ScopeGuard: lexical scope management that makes forgetting close_scope() impossible (P1-13).
Container guardwith_container and ContainerGuard: container lifecycle management with exactly-once close() (P1-14).
Patterns and best practicesComposition roots, configuration, shared state, ports and adapters under value semantics, anti-patterns.
FAQShort answers to the questions that come up most often.

Correctness and errors

DocumentWhat it covers
Compile-time validationEverything mjdi rejects before your program runs, when the checks fire, and the detection boundaries.
DiagnosticsThe complete catalog of compile-time errors, runtime raises, and aborts — exact message text and how to fix each — plus the machine-readable quick-fix catalog.
Re-entrancyThe runtime guard against resolution cycles compile-time validation cannot see: what it detects, the diagnostic path, the cost, and the opt-out (P1-20).
Construction orderingThe deterministic construction, caching, and teardown contract — release order, factory order, and why it is testable (P1-18).
ConcurrencyThe single-threaded-per-container contract, external synchronization, and what changes if the toolchain grows threads (P1-19).
Ownership and memoryWho owns which instance, Copyable requirements, destruction, and why disposal is explicit (the opt-in lifecycle hooks).

Trust, correctness, and release readiness (P0)

DocumentWhat it covers
Release metadata and versioningThe canonical release manifest, the synced locations, the validator, and the version-update workflow (P0-01).
Compiler compatibilityThe evidence-based platform matrix: verified / ci-verified / experimental / unsupported tiers and what backs them (P0-02).
Lifecycle safety diagnosticsThe opt-in debug_tracking specialization: tracked caches, close records, and the destructor-time unclosed-resource diagnostics MJDI-D001/D002 (P0-03).
Close semanticsThe exact, test-pinned behavior of Container.close() and Scope.close_scope() (P0-04).
Lifecycle failure policyWhat happens when cleanup fails: the non-raising pre_destruct contract, exactly-once cleanup, and the post_construct failure path (P0-05).
Validation output contractThe stable diagnostic-ID system: pinned IDs, the ID policy, and the compiler-diagnostic limitations (P0-06).
Test inventoryThe authoritative suite inventory, the four distinct coverage categories, and the 54/55 reconciliation (P0-07).
Runtime error referenceThe four runtime error categories with stable IDs, context, and remediation (P0-08).
Alias semanticsThe complete alias contract: lifetimes-not-instances, cache ownership, precedence, and why chains are impossible (P0-09).
Scope behavior matrixThe provider/lifetime/scope matrix with cache ownership — every row test-pinned (P0-10).
Release checklistThe release gate, the CI jobs, and the manual pre-tag checklist.
Migration notesEvery 0.9.0 change classified: additive / behavior clarification / bug fix / deprecation / breaking.
Migration guide: 0.7 → 0.8The actual 0.8.0 API delta with before/after examples and verification steps.
Migration guide templateThe structure every future release's migration guide extends.

Reference

DocumentWhat it covers
API referenceEvery public symbol, organized by area — signatures generated from the source so they cannot drift (P1-12).
Documentation websiteThe website serving this set: versioned URLs, copy-as-markdown, raw endpoints, search, version switcher.
Graph exportgraph_json / graph_dot: the deterministic, versioned dependency-graph export (P1-01).
Graph visualizationThe interactive graph viewer in the documentation website (P1-02).
Graph diffComparing two exports with CI-friendly exit codes (P1-03).
Explain resolutionexplain_resolution: why a service resolves the way it does (P1-04).
Composition rootsThe four starter templates and what each demonstrates (P1-05).
TestingThe test suite, compile-fail fixtures, golden outputs, the testing patterns, and the static coverage methodology and its 95% gate.
Lifecycle tracingThe opt-in, deterministic event log (P1-15).
Cache statisticsThe opt-in cache-activity counters (P1-16).
PerformanceThe benchmark suite, methodology, recorded results, and the regression policy (P1-17).
IDE integrationThe diagnostic catalog schema, problem matchers, and the editor integration starter (P1-11).
MCP serverThe /api/mcp Model Context Protocol endpoint: transport, tools, resources, error model, client configuration.
ChangelogRelease history.

Design and internals

DocumentWhat it covers
ArchitectureComponents, the compile-time/runtime split, the registry chain, dispatch mechanics, design rationale.
Technical investigationThe compiler-feature verification matrix (33 verified/unsupported rows plus implementation findings) behind every design decision.
Known limitationsWhat Mojo 1.2.0 cannot express, the workarounds, and every deviation from the product requirements.
Release reportThe 0.9.0 implementation, test, compatibility, and readiness report (deliverables A-F).
Acceptance criteriaThe status of every product requirement and functional requirement.

Suggested reading paths

Where the truth lives

  • Behavior is defined by the source in mjdi/ and pinned by the test suite (tests/, driven by scripts/run_tests.sh; the authoritative inventory reports 114/114 suite checks — see ../tests/INVENTORY.md — pass on Mojo 1.2.0 — unit, compile-fail, crash-expected, golden examples, templates, and the Python tooling checks).
  • Coverage claims come from scripts/coverage_report.py (library API surface: 814/814 declarations, 100%) and scripts/example_coverage.py (example declarations: 166/166, 100%), both gated at 95%.
  • Compiler claims are backed by experiments/exp1 through exp10 and the compile-fail fixtures in tests/compile_fail/.
  • Suite and coverage counts come from the generated test inventory (tests/INVENTORY.md, P0-07); release metadata is validated against release/manifest.json (P0-01).
  • Performance claims are backed by benchmarks/ with the recorded results in benchmarks/RESULTS.md (P1-17).
  • If a document and the code ever disagree, the code and its tests win — please report the doc issue.