Monata API Boundaries¶
Monata separates stable public APIs from internal implementation details. The 0.1.x public names should usually live only in their owning modules rather than being carried through transitional facades. The only standing exception is a deliberately small root facade for foundational package concepts.
Stable public APIs¶
monata.library,monata.cell,monata.registry, andmonata.workspacefor project/library/cell metadata and lookup.monata.netlistfor native netlist IR types, mutation, and rendering:Circuit,SubCircuit,Element,Directive,SourceValue,MutationError,MutationProjection,apply_mutation,project_param_overrides, andrender_ngspice.Circuit.to_spice(),SubCircuit.to_spice(),Element.to_spice(),Directive.to_spice(),ModelCard.to_spice(), andSourceValue.to_spice()are explicit convenience methods for rendering native objects through the same owned renderer. Native scopes also own stable element lookup and edit operations through methods such asget_element(),element(),remove_element(), andreplace_element(), plus node-name inspection throughget_node(),node(), andhas_node(). Node helpers return native node-name strings rather than a separate public node object model.get_node(name, create=True)andnode(name, create=True)may pre-register loose node names for authoring and topology handoff without rendering standalone SPICE lines. Attribute access such asscope.Rloadis a convenience lookup for uniquely named elements and does not replace explicit lookup/edit APIs.Element.parameters,Directive.parameters,SourceValue.parameters,Element.get(),Directive.get(),SourceValue.get(),Element[...],Directive[...],SourceValue[...], and missing attribute lookup expose read-only access to native record parameters.Element.clone(),Directive.clone(), andSourceValue.clone()are native record-copy helpers for immutable-style edits before replacing or reusing records in a scope. Disabled elements remain addressable records throughElement.enabled = Falsebut are omitted by scope rendering.Element.commentis rendered as a preceding SPICE comment line by the owned renderer.Element.raw_suffixis the element-level one-line escape hatch for unsupported trailing tokens after structured parameters; prefer structuredparamswhenever Monata can represent a token. Scope-level raw simulator text belongs in ordered raw directives throughraw_directive()andraw_block(); this remains a line-oriented escape hatch rather than a second mutable netlist model. Convenience helpers such asCircuit.resistor()andCircuit.mos()reserve their Python argument names for structural fields like element name, nodes, value, and model. When a simulator parameter must use one of those names, use the explicit IR escape hatch: constructElement(..., params=...)and add it withCircuit.add().monata.netlist.device_schemaowns optional element/pin/parameter metadata records.monata.netlist.topologyowns the optional editable node/pin graph that can be projected back into the record IR; the record IR remains the render/simulation boundary.monata.circuitsfor reusable circuit construction helpers such as CMOS transistor/gate helpers and source-subcircuit construction helpers. Project-specific topology recipes, such as a fixed library multiplier, belong in the owning circuit library.monata.cornerfor the canonicalOperatingCornermodel shared by techlib and simulation.monata.views.registryfor registering and resolving view type factories.monata.cell.Cell.write_generated_viewowns generated artifact writes and metadata commits.monata.generationowns generated symbol/netlist content construction and calls that public cell boundary.monata.techlib.registry,monata.techlib.schema, andmonata.techlib.projectionfor techlib loading, registry discovery, schema records, PDK instance validation, and projection records.monata.techlibis a namespace package surface, not a compatibility facade.monata.projectionfor resolving PDK projection owner context and applying validated source-level PDK instances into netlist scopes.monata.parserfor SPICE import and conversion entry points:parse_spice_to_circuit,import_spice_deck,import_spice_asset,spice_to_python,inspect_spice_import,inspect_spice_analysis,spice_to_sim_tasks,parse_spice_expression,render_spice_expression,walk_spice_expression,parse_source_subcircuit,ImportedAsset,SpiceImportPlan,SpiceImportStep,SpiceImportExpressionCheck,SpiceControlCommand,SpiceSourceDependency,SpiceImportIssue,SpiceAnalysisPlan,SpiceAnalysisStep,SpiceAnalysisMeasurement,SpiceAnalysisSweep,SpiceAnalysisIssue,SpiceExpressionand its concrete expression record types,SourceSubcircuit,SourceSubcircuitInstance,SpiceParseError, andUnsupportedConstructError. SPICE import is a two-stage boundary: recognized commands are either projected into native Monata IR, used for import flow control, or preserved as raw directives for the simulator. Import inspection exposes those decisions and unsupported constructs without turning parsed SPICE into a second public netlist model. Analysis import is a separate parser boundary: deck-level.tran/.ac/.opand related commands may be projected into backend-neutralSimTaskrecords while the base circuit is rendered without duplicate analysis directives. Pure task-style.controlblocks may also be migrated when they contain only analysis, measurement, output-vector, and ignorable run/quit commands; stateful or side-effecting control scripts remain outside the SimTask migration contract. Imported.measurecommands are exposed as plan records and filtered into the matching task’s circuit and metadata; they are not promoted into a second Monata measurement DSL. Imported.step paramsweeps are exposed as sweep records and expand into multipleSimTaskinstances withparam_overrides; imported.step tempsweeps expand into task operating corners. Step imports supportlist, linear, decade, and octave sweep forms at this analysis boundary. The native netlist IR still preserves.stepas raw text outside the analysis-import boundary. String inputs are treated as SPICE text; filesystem reads require an explicitPath. The expression parser is a lightweight inspect/render frontend for SPICE math expressions; it does not evaluate parameters or own netlist semantics. Import plans may attach expression checks and warning diagnostics to expression-like fields, but native projection still preserves the original string values. LTspice/RKM number forms such as2k3are accepted only through explicit dialect options on expression-oriented APIs, not as the default SPICE number contract..controlblocks remain raw simulator text at projection time, but import plans classify internal commands so analysis/measure migration candidates and side-effecting control commands are visible..includeand.libreferences are exposed as source dependency records with optional search-path resolution diagnostics; import inspection does not recursively load those files or replacemonata.spice_library/project-library ownership. Common ngspice aliases and library-section markers such as.measand.endlare accepted at the import boundary; projected measurements use Monata’s canonical measure directive representation.monata.eda.kicadfor KiCad XML netlist import. The adapter parses KiCad components/nets, reports a component-level import plan, and projects supported components into nativeCircuit/Elementrecords or a generated Monata netlist cell view. It can also export a supported netlist projection as Python builder source for editable handoff. It is a front-end adapter, not a schematic object model.monata.spice_libraryfor indexing third-party SPICE model/subcircuit files. This is separate frommonata.library, which remains the Monata project cell library abstraction. The index may expose lightweight category/tag metadata for discovery and may attach indexed items to native netlist scopes as.include/.libreferences. Indexed items may return their original source.model/.subcktsnippets for downstream import or inspection, but the library index does not own a full SPICE AST and does not define a fixed vendor or product catalog schema.monata.sim.analysis_spec,monata.sim.task,monata.sim.results,monata.sim.waveform,monata.sim.executor, andmonata.sim.vector_namesown the core simulation contracts.monata.sim.coreis a stable convenience import bundle over those owner modules; it should not contain implementation logic or become a broad compatibility facade. Its export set is intentionally locked by public API tests; add a newcoreexport only when the name belongs in the small simulation kernel rather than a specialized workflow module. Sweep and Monte Carlo orchestration belong inmonata.sim.sweepandmonata.sim.montecarlo; digital testbench orchestration belongs inmonata.sim.digital_tableand related digital owner modules. Those workflow modules are public owner-module APIs, but they are intentionally not part of themonata.sim.corecompatibility bundle.monata.sim.taskowns simulation input contracts such asSimTask, task defaults, output-name normalization, andSimArtifactOptions.monata.sim.resultsowns execution output contracts such asSimResult,SimStatus,AnalysisResult, waveform lookup, result payload aliases, and array-to-result construction.monata.sim.result_opsowns result-level numeric transforms such as derivative, integral, resampling, sampling, and windowing;AnalysisResultkeeps thin method wrappers for ergonomic use. TypedWaveform/AnalysisResultobjects may expose plotting-neutral data projections such as magnitude, phase, derivative, integral, and ordered numeric/unit-array column projection, including Bode traces derived from frequency-domain analysis results.monata.sim.vector_namesowns output vector identity helpers such asnormalize_vector_name()andVectorName. Itsvoltage_vector(),branch_current_vector(),node_current_vector(),device_parameter_vector(),internal_parameter_vector(), andexpression_vector()helpers are Monata-owned request builders; bareSimTask.output_namesentries remain node-voltage shorthand. Result groupings use explicit Monata names such asnode_voltages_by_node,branch_currents_by_element, andelement_parameters. Measurement pass/fail semantics remain inmonata.measure.SimTask.metadatais descriptive user/task metadata, not a backend control channel. Backend-specific execution controls belong inSimTask.backend_options; simulator artifact persistence belongs inSimTask.artifacts/SimArtifactOptions. Backend results may promote stable Monata result descriptors such as analysis names, requested/observed vectors, measures, artifacts, and compact execution summaries to top-level result metadata, but backend-only diagnostics remain under the backend namespace such asmetadata["ngspice"]. Monata-owned workflow control payloads use reserved, versioned namespaces undermetadata["monata"]; digital truth-table task scheduling data lives inmetadata["monata"]["digital_task_v1"]with schemamonata.sim.digital-task.v1, while caller descriptive metadata remains at the task metadata top level. Simulation results that need digital task reconstruction carry that task metadata only throughSimResult.metadata["task_metadata"]; older top-level control keys are not accepted.monata.sim.sessionfor the stateful simulation-session builder facade over circuit directives, raw directive blocks, and backend-neutralSimTaskcreation. Session-level metadata, backend options, and artifact options are copied into tasks and may be overridden per task. Because the session facade is mutable, tasks snapshot the session circuit by default; explicitsnapshot_tasks=False/snapshot=Falseopts back into sharing the live circuit object.monata.sim.analysis_specfor immutable user-facing analysis contracts and their generic canonical analysis names.monata.sim.cachefor content-addressedSimTaskfingerprints and optional filesystem result caching. The cache key is derived from simulation inputs such as rendered circuit text, analysis spec, corner, parameter overrides, output requests, backend options, task metadata, and referenced model/include/OSDI artifact digests. Timeout and artifact output destination remain outside the identity contract.monata.sim.backendsfor backend protocol, capability, task-validation, task-planning, and registry APIs. The built-in ngspice runner remainsngspice-subprocess;ngspice-sharedis the same-simulator runner for libngspice command/session workflows and requires an available user-provided shared library. Backend extension points are explicit: implementBackend.run()for execution,ValidatingBackend.validate_task()for preflight failures, andPlanningBackend.plan_task()for backend-facing plan introspection. Ngspice backends preserve ordinary simulator and parser failures as failedSimResultvalues by default; setbackend_options["raise_backend_exceptions"] = Truewhen development or CI should surface backend adapter exceptions directly.monata.sim.capabilitiesfor simulator model-flow profiles used when resolving model artifacts and device-level simulator support. These profiles describe a simulator family/dialect and model support; they are not backend registry entries and do not replacemonata.sim.backends.BackendCapabilities.monata.sim.digital_tablefor the user-facing digital truth-table construction/execution facade,monata.sim.digital_resultsfor digital truth-table result and propagation-delay row records,monata.sim.digital_claimsfor digital oracle/comparison records, andmonata.sim.digital_projectionfor PDK projection helpers used by digital flows. Internal digital task construction and result extraction share explicit plan/schedule/stimulus-metadata records frommonata.sim.digital_planinstead of depending onDigitalTruthTableprivate methods or untyped result metadata reads. Digital table timing options are behavioral contracts:skew_stepoffsets each input source transition and the corresponding extraction schedule by input index.Digital workflows do not have a compatibility aggregation module; import from the owner modules above.
monata.simis a namespace package surface, not a compatibility facade.monata.sim.exportfor simulation result serialization helpers, including HDF5 export/import through the defaulth5pyruntime dependency.monata.sim.rawfilefor loading external ngspice rawfiles into typedAnalysisResult/Waveformrecords. Rawfile parser records undermonata.sim.backendsremain backend implementation details. Ngspice-specific header fields such as circuit name, date, warnings, and TEMP/TNOM are preserved as result metadata. Optional node/element name lists may restore result display casing without changing the underlying raw vector provenance.monata.unitsandmonata.physicsfor circuit-oriented scalar/array unit values, SPICE suffix parsing, and small sizing/thermal helper formulas.
Root facade¶
monata may re-export foundational names that are needed before a user chooses a
simulation, circuit-construction, techlib, or backend workflow:
Cell,Library,LibraryRegistry, andView.OperatingCorner.Common Monata errors.
Quantity,Unit, andUnitArray.
The root facade must stay lightweight: importing monata must not import
monata.sim, monata.sim.backends, backend implementation modules, or optional
plotting/model execution dependencies.
Internal implementation details¶
Import-time backend registration, simulator planning internals, parser record types such as
monata.parser.deck.SpiceDeck, and view-loading mechanics are implementation details unless explicitly re-exported in the stable API.Python-backed schematic and testbench views are trusted project code. Calling
View.load()or APIs that generate/load those views executes Python in the current process; Monata does not sandbox view code.Private attributes on netlist scopes and mutation indexes are not extension points.
Generation implementation details live under
monata.generation; higher-level cell methods may call those services but should not duplicate them.Projection algorithms live under
monata.projection; higher-level library methods may call those services but should not duplicate them.
Ownership rule¶
When adding or moving an API:
Put the implementation and public export in the owner module.
Update callers and documentation to import from the owner module directly.
Do not add root-package exports unless the name belongs in the small foundational facade above.
Do not add new cross-module compatibility re-exports during pre-release development. Prefer owner-module imports over migration shims.
Cover boundary decisions with tests when the import path is user-facing.