{"sections":[{"heading":"Prepare a matching Python distribution","paragraphs":["Use Python and a JoSIM 2.9 module/core combination supplied for that Python ABI and architecture, with an existing issued JoSIM licence. A version label alone does not establish binary compatibility. The checked candidate is a private current-source Windows build for CPython 3.13.11; final distributed packages and other platforms still require verification.","Extract both teaching files into a new writable folder. Set $Python to the compatible interpreter, $ModuleDir to the directory containing the matching module/core and its supplied runtime dependencies, and $Licence to the issued JoSIM licence file path. Keep the source and results separate. The example changes only its own process and writes no installed settings.","On Windows, use the runtime dependencies supplied with the matching distribution. Avoid adding a whole compiler tools directory to find one dependency: it can load an older MSVCP140 runtime. In the review setup this caused a crash at Settings.license despite successful import; restricting the search to the coherent distribution resolved it. Check loaded dependencies before treating that symptom as a licence rejection, and use the supported package repair rather than copying arbitrary DLLs into installed software.","These execution checks use the retained source freeze. Later maintained UTF-8 path changes were reviewed separately; Unicode paths and that later binary set were not exercised here."]},{"code":"* Synthetic resistive example for Runtime precedence, not a device model\nV1 IN 0 DC 1m\nR1 IN 0 50\n.OPTION ANALYSIS=PHASE INTEGRATION=BDF SEED=321 OUTPUTPRECISION=12 COMPRESSED=OFF VARSTEP=OFF NEWTONJJ=OFF\n.TRAN 1p 20p 0p 1p\n.PRINT V(IN) I(R1)\n.END","heading":"Save precedence.cir","language":"spice"},{"heading":"Separate defaults from explicit overrides","paragraphs":["Settings contains process-wide licence/presentation state; Runtime supplies per-run controls. Runtime.fromGlobalSettings() remains a convenience constructor for a default Runtime and does not copy Settings fields into it. Inspect PUBLIC_RUNTIME_FIELDS for the supported field surface.","Runtime.override_mask starts at zero. Assigning a field supplies a default; selecting its bit makes it outrank global and block-local deck options. Combine bits with |. Clearing the mask restores deck precedence without resetting the stored values. Unknown bits are rejected without changing the mask.","analysisType uses 0=PHASE and 1=VOLTAGE; integrationMethod uses 0=BDF and 1=TRAP. Timing and UIC retain their deck rules; they have no general override bit. Only the JJ Newton enable policy has a bit, separately from its tolerances and iteration limit."],"table":{"columns":["Python constant","Setting given explicit precedence"],"rows":[["OVERRIDE_ANALYSIS","PHASE or VOLTAGE formulation"],["OVERRIDE_INTEGRATION","BDF or TRAP integration"],["OVERRIDE_COMPRESSION","Native text-output compression"],["OVERRIDE_PRECISION","Output precision"],["OVERRIDE_SEED","Unsigned 64-bit seed"],["OVERRIDE_VARSTEP","Variable-step enable policy"],["OVERRIDE_NEWTONJJ","JJ Newton enable policy, separately from its tolerances"],["OVERRIDE_ALL","All seven supported override fields"]],"wrap":true}},{"heading":"Compare the three complete cases","paragraphs":["All cases retain the explicit .TRAN step of 1 ps and stop of 20 ps despite caller timing defaults of 4 ps and 12 ps. Each accepted case writes 21 samples, V(IN) and I(R1), plus its planned configuration and completed record. Full-width integer seeds survive without a floating-point conversion; a fixed seed in a noiseless resistor example does not qualify stochastic reproducibility."],"table":{"columns":["Case","Resolved formulation / method","Seed / output precision","Value origins"],"rows":[["deck","PHASE / BDF","321 / 12","All seven controls come from the deck"],["override","VOLTAGE / TRAP","18446744073709551615 / 17","Analysis, integration, seed and precision use run_override; the other three retain netlist"],["cleared","PHASE / BDF","321 / 12","The stored caller values remain, but mask zero restores netlist precedence"]],"wrap":true}},{"heading":"Run the complete Python comparison","paragraphs":["Run this from the extracted teaching folder after assigning the three variables above. results-first must not already exist. The helper intentionally refuses a reused output directory; choose a fresh destination after inspecting an interrupted attempt.","The script asserts precedence and origins before executing. It checks the completed record and committed file, parses raw-SI CSV, checks finite values and 21 aligned samples, and compares the teaching resistor with 1 mV and 20 microamps using 1e-9 relative plus 1e-15 absolute tolerance. These are synthetic transfer checks, not general device-accuracy limits.","The PHASE/BDF cases store zero voltage in the initial row of this example; their positive-time voltages are 1 mV and their current is 20 microamps throughout. The VOLTAGE/TRAP case directly stores 1 mV in every row. The checker distinguishes that initial representation rather than silently dropping the first row."],"code":"& $Python -B .\\run_precedence.py --module-dir $ModuleDir --licence $Licence --output-root .\\results-first\nif ($LASTEXITCODE -ne 0) { throw 'Runtime precedence check failed; inspect the first diagnostic and retained outputs.' }","language":"powershell","steps":["Extract both supplied files together into a new writable teaching folder.","Assign $Python, $ModuleDir and $Licence to the intended compatible interpreter, coherent distribution and issued JoSIM licence path.","Run the exact PowerShell block from that folder with a new results-first destination.","Read summary.json and all three current CSVs; inspect planned origins and the completed committed-file receipts.","If a check fails, retain diagnostics and partial output, correct the cause and construct a fresh plan in a new destination."]},{"code":"\"\"\"Compare deck precedence, selected overrides and a cleared override mask.\"\"\"\nimport argparse\nimport csv\nimport hashlib\nimport json\nimport math\nimport os\nfrom pathlib import Path\nimport sys\n\nMAX_SEED = 18446744073709551615\n\n\ndef sha(path):\n    return hashlib.sha256(path.read_bytes()).hexdigest()\n\n\ndef load_module(directory):\n    # Change only this process. Keep the DLL-directory handle alive until exit.\n    handles = []\n    if directory:\n        directory = directory.resolve(strict=True)\n        if sys.platform == 'win32':\n            handles.append(os.add_dll_directory(str(directory)))\n        sys.path.insert(0, str(directory))\n    import josimpro as jp\n    return jp, handles\n\n\ndef build_plan(jp, source, directory, mode, events):\n    rt = jp.Runtime()\n    rt.workingDir = str(directory)\n    rt.inputFile = str(source)\n    rt.analysisType = 1\n    rt.integrationMethod = 1\n    rt.seed = MAX_SEED\n    rt.outputPrecision = 17\n    rt.tStep = 4e-12\n    rt.tStop = 12e-12\n    rt.progressFn = lambda stage, current, total: events.append(('progress', stage))\n    rt.progressDetailFn = lambda kind, text: events.append(('detail', kind))\n    selected = jp.OVERRIDE_ANALYSIS | jp.OVERRIDE_INTEGRATION | jp.OVERRIDE_SEED | jp.OVERRIDE_PRECISION\n    if mode in ('override', 'cleared'):\n        rt.override_mask = selected\n    if mode == 'cleared':\n        rt.override_mask = 0\n    rt.set_output_file(mode + '.csv')\n    inp = jp.Input()\n    inp.runtime = rt\n    inp.read_input()\n    inp.parse_input()\n    return rt, inp, jp.AnalysisJobs(inp, True)\n\n\ndef checked_run(jp, source, directory, mode):\n    events = []\n    rt, inp, jobs = build_plan(jp, source, directory, mode, events)\n    snapshot_text = jobs.effective_settings_json(0)\n    before = len(events)\n    assert jobs.effective_settings_json(0) == snapshot_text\n    assert len(events) == before, 'Inspecting cached settings invoked callbacks'\n    preview = json.loads(snapshot_text)\n    explicit = mode == 'override'\n    expected = {'analysisType': int(explicit), 'integrationMethod': int(explicit),\n                'seed': MAX_SEED if explicit else 321,\n                'outputPrecision': 17 if explicit else 12,\n                'compressedOutput': False, 'variableStepEnabled': False,\n                'newtonJJEnabled': False}\n    assert preview['schema'] == 'josim-run-configuration/1'\n    for field, value in expected.items():\n        assert preview[field] == value, (mode, field, preview[field])\n        origin = 'run_override' if explicit and field in ('analysisType', 'integrationMethod', 'seed', 'outputPrecision') else 'netlist'\n        assert preview['setting_origins'][field]['origin'] == origin\n    assert preview['tStep'] == 1e-12 and preview['tStop'] == 20e-12\n    assert preview['outputs'][0]['format'] == 'CSV'\n    destination = directory / (mode + '.csv')\n    assert Path(preview['outputs'][0]['path']) == destination\n    assert not destination.exists(), 'Preview unexpectedly wrote numerical output'\n    (directory / (mode + '-planned.json')).write_text(snapshot_text + '\\n', encoding='utf-8')\n    jobs.run()\n    record = json.loads(jobs.result_record_json(0))\n    assert record['schema'] == 'josim-run-record/1' and record['status'] == 'succeeded'\n    assert record['completion'] == 'completed' and record['files'][0]['committed']\n    assert record['seed'] == expected['seed']\n    with destination.open(encoding='utf-8-sig', newline='') as stream:\n        rows = list(csv.reader(stream))\n    assert rows[0] == ['time', 'V(IN)', 'I(R1)'] and len(rows) == 22\n    values = [[float(v) for v in row] for row in rows[1:]]\n    assert all(len(row) == 3 and all(math.isfinite(v) for v in row) for row in values)\n    for index, (time, voltage, current) in enumerate(values):\n        assert math.isclose(time, index * 1e-12, rel_tol=1e-12, abs_tol=1e-24)\n        # PHASE reconstructs voltage from phase differences. Its first stored\n        # voltage is zero here; compare the Ohm-law voltage at positive times.\n        assert math.isclose(voltage, 0.0 if index == 0 and not explicit else 0.001, rel_tol=1e-9, abs_tol=1e-15)\n        assert math.isclose(current, 0.001 / 50, rel_tol=1e-9, abs_tol=1e-15)\n    assert len(jobs.results[0].axis) == 21 and len(jobs.results[0].traces) == 2\n    (directory / (mode + '-record.json')).write_text(jobs.result_record_json(0) + '\\n', encoding='utf-8')\n    return {'resolved': expected, 'rows': len(values), 'committed': True,\n            'callbacks_observed': bool(events), 'csv_sha256': sha(destination)}\n\n\ndef main():\n    parser = argparse.ArgumentParser(description=__doc__)\n    parser.add_argument('--module-dir', type=Path, help='Directory of a matching module/core distribution')\n    parser.add_argument('--licence', type=Path, help='Existing issued JoSIM licence file; never its contents')\n    parser.add_argument('--output-root', type=Path, required=True, help='New directory; reused paths are refused')\n    args = parser.parse_args()\n    source = Path(__file__).resolve().with_name('precedence.cir')\n    original = sha(source)\n    output = args.output_root.resolve()\n    output.mkdir(parents=True, exist_ok=False)\n    jp, handles = load_module(args.module_dir)\n    if args.licence:\n        jp.Settings.license = str(args.licence.resolve(strict=True))\n    jp.Settings.minOutput = True\n    identity = json.loads(jp.core_identity_json())\n    assert identity['version'] == '2.9.0', 'Use the qualified matching 2.9 distribution'\n    results = {mode: checked_run(jp, source, output, mode) for mode in ('deck', 'override', 'cleared')}\n    assert sha(source) == original\n    summary = {'status': 'passed', 'scope': 'Synthetic Windows review example; not general accuracy or release qualification',\n               'source_sha256': original, 'core_version': identity['version'],\n               'core_sha256': identity['sha256'], 'cases': results}\n    (output / 'summary.json').write_text(json.dumps(summary, indent=2) + '\\n', encoding='utf-8')\n    print(json.dumps(summary, indent=2))\n    # handles deliberately remain live through all native calls.\n    assert isinstance(handles, list)\n\n\nif __name__ == '__main__':\n    main()","heading":"Save run_precedence.py","language":"python"},{"heading":"Inspect a fresh plan and its actual receipt","paragraphs":["Set workingDir and inputFile, then attach Runtime to an empty Input before read_input() and parse_input(). Input(\"file.cir\") reads and parses immediately. Construct a fresh single-use AnalysisJobs plan after source/settings changes.","effective_settings_json(index) is cached josim-run-configuration/1 JSON. Inspect requested_defaults, resolved top-level values, setting_origins, source locations, override_mask, seed and outputs. Repeated inspection does not call progress callbacks or write numerical output. Later edits to the caller Runtime do not mutate the existing plan.","After run() returns, inspect result_record_json(index): status=succeeded, completion=completed and the intended files[].committed must agree with fresh numerical data. These receipts describe calculation/publication separately. Calling run() twice on the same plan is rejected.","Keep copied callback data short and inspect the plan only before or after run(). The run releases the GIL and callbacks may run synchronously on its worker. Use request_abort() for cancellation; do not query or mutate an active plan. Only callback lifetime, real callback observation and cached-preview behaviour were exercised here; concurrent cancellation/exception paths still need dedicated checks."]},{"heading":"Keep output routing and input protection explicit","paragraphs":["set_output_file resolves a relative destination against workingDir at setter time, not when the plan later runs. Set workingDir first. Changing it later does not move that already selected output. Empty text clears the primary destination and restores subsequent .FILE routing.","The checked runtime rejects writing over the source and over a hardlink alias of it. Invalid timing leaves an existing destination unchanged; a successful publication replaces the existing output. Preview alone neither writes nor reserves a future destination. Preserve source/include/model identity and construct a fresh plan after changes.","The separate all-seven-bit control resolves every origin to run_override and runs PHASE+BDF variable-step mode with JJ Newton enabled and gzip output. This confirms the control/receipt route on a resistor; it does not qualify nonlinear junction convergence or all variable-step circuits. VOLTAGE+TRAP with variable-step enabled is rejected through DiagnosticError with messages, category and cancelled state."]},{"heading":"Recognise the two retained discrepancies","paragraphs":["KB-RUNTIME-001: explicit seed=0 with OVERRIDE_SEED selects a nonzero seed, and the cached preview matches the completed record, but seed_mode reports fixed in this candidate. requested_defaults.seed remains 0 and its origin is run_override. Preserve both the request and resolved seed; do not infer that the caller chose a fixed seed from this label alone. Automatic-seed uniqueness/quality is outside these checks.","KB-TRAP-001: keeping PHASE and overriding only integration to TRAP on this constant 1 mV / 50 ohm deck produces alternating 0 and 40 microamp current while positive-time voltage remains 1 mV. A separate CLI run reproduces it at matching output precision. The ideal branch current is 20 microamps. Both runs report success, so success metadata alone does not qualify the values.","The complete accepted example uses PHASE/BDF and VOLTAGE/TRAP with independent resistor checks. Treat the PHASE/TRAP counterexample as unresolved; do not generalise either result to all TRAP circuits or silently change a real circuit’s formulation. Root cause, startup/timestep sensitivity, other platforms and final packages remain to be investigated."]},{"heading":"Check the result","paragraphs":["Expect summary.json with status passed and three committed 21-row CSVs. Retain the exact source bytes, requested/resolved settings, actual module/core identity and completed receipts. A partial directory, an old output or a finite plot does not establish success."]},{"heading":"If the problem remains","paragraphs":["Check the first Python/native diagnostic, compatible interpreter/module/core and actual DLL dependencies. When a setter appears ineffective, inspect the deck option and corresponding override bit. For a failed run preserve existing results, correct the input/destination and construct a fresh plan in a new output directory. Do not adjust solver tolerances to hide a precedence or dependency problem."]}],"canonical_url":"https://www.sun-magnetics.com/knowledge-base/josim-runtime-precedence","decimal_integer_fields":[".provenance.execution_checks.0.observed.override_seed"],"url":"/knowledge-base/josim-runtime-precedence","known_issues":[{"disposition":"supported_path","id":"KB-RUNTIME-001","title":"An automatic seed request is labelled fixed","public_notice":"Use explicit nonzero seeds for the teaching comparison and preserve both the requested seed mode and resolved seed. The fixed label alone does not establish how an automatic seed was chosen.","claim_scope":"Only the affected claim and recorded build/input; not whole-guide or final-release acceptance"},{"disposition":"hold","id":"KB-TRAP-001","title":"PHASE/TRAP constant-source resistor current alternates","public_notice":"The PHASE/TRAP resistor control fails its independent current reference. The separate PHASE/BDF and VOLTAGE/TRAP teaching controls pass; do not infer a safe formulation change for an arbitrary real circuit.","claim_scope":"Only the affected claim and recorded build/input; not whole-guide or final-release acceptance"}],"search_record":{"execution":true,"relatedProducts":[],"version_tags":["JoSIM-Pro 2.9 target"],"text":"Understand Python Runtime defaults and netlist overrides Inspect the resolved plan, choose explicit overrides only where intended, and verify fresh numerical output with a complete three-case Python example. JoSIM-Pro 2.9.0 release target; matching isolated Windows Python review module/core How to python runtime settings override mask precedence defaults analysis type effective_settings_json requested_defaults setting_origins cached preview uint64 seed 18446744073709551615 automatic seed fixed label relative set_output_file setter time output source hardlink collision PHASE TRAP resistor current alternates 0 40 microamps Python MSVCP140 old compiler DLL search crash runtime dependency DiagnosticError messages category cancelled callbacks GIL Prepare a matching Python distribution Use Python and a JoSIM 2.9 module/core combination supplied for that Python ABI and architecture, with an existing issued JoSIM licence. A version label alone does not establish binary compatibility. The checked candidate is a private current-source Windows build for CPython 3.13.11; final distributed packages and other platforms still require verification. Extract both teaching files into a new writable folder. Set $Python to the compatible interpreter, $ModuleDir to the directory containing the matching module/core and its supplied runtime dependencies, and $Licence to the issued JoSIM licence file path. Keep the source and results separate. The example changes only its own process and writes no installed settings. On Windows, use the runtime dependencies supplied with the matching distribution. Avoid adding a whole compiler tools directory to find one dependency: it can load an older MSVCP140 runtime. In the review setup this caused a crash at Settings.license despite successful import; restricting the search to the coherent distribution resolved it. Check loaded dependencies before treating that symptom as a licence rejection, and use the supported package repair rather than copying arbitrary DLLs into installed software. These execution checks use the retained source freeze. Later maintained UTF-8 path changes were reviewed separately; Unicode paths and that later binary set were not exercised here.  Save precedence.cir * Synthetic resistive example for Runtime precedence, not a device model\nV1 IN 0 DC 1m\nR1 IN 0 50\n.OPTION ANALYSIS=PHASE INTEGRATION=BDF SEED=321 OUTPUTPRECISION=12 COMPRESSED=OFF VARSTEP=OFF NEWTONJJ=OFF\n.TRAN 1p 20p 0p 1p\n.PRINT V(IN) I(R1)\n.END Separate defaults from explicit overrides Settings contains process-wide licence/presentation state; Runtime supplies per-run controls. Runtime.fromGlobalSettings() remains a convenience constructor for a default Runtime and does not copy Settings fields into it. Inspect PUBLIC_RUNTIME_FIELDS for the supported field surface. Runtime.override_mask starts at zero. Assigning a field supplies a default; selecting its bit makes it outrank global and block-local deck options. Combine bits with |. Clearing the mask restores deck precedence without resetting the stored values. Unknown bits are rejected without changing the mask. analysisType uses 0=PHASE and 1=VOLTAGE; integrationMethod uses 0=BDF and 1=TRAP. Timing and UIC retain their deck rules; they have no general override bit. Only the JJ Newton enable policy has a bit, separately from its tolerances and iteration limit.  Python constant Setting given explicit precedence OVERRIDE_ANALYSIS PHASE or VOLTAGE formulation OVERRIDE_INTEGRATION BDF or TRAP integration OVERRIDE_COMPRESSION Native text-output compression OVERRIDE_PRECISION Output precision OVERRIDE_SEED Unsigned 64-bit seed OVERRIDE_VARSTEP Variable-step enable policy OVERRIDE_NEWTONJJ JJ Newton enable policy, separately from its tolerances OVERRIDE_ALL All seven supported override fields Compare the three complete cases All cases retain the explicit .TRAN step of 1 ps and stop of 20 ps despite caller timing defaults of 4 ps and 12 ps. Each accepted case writes 21 samples, V(IN) and I(R1), plus its planned configuration and completed record. Full-width integer seeds survive without a floating-point conversion; a fixed seed in a noiseless resistor example does not qualify stochastic reproducibility.  Case Resolved formulation / method Seed / output precision Value origins deck PHASE / BDF 321 / 12 All seven controls come from the deck override VOLTAGE / TRAP 18446744073709551615 / 17 Analysis, integration, seed and precision use run_override; the other three retain netlist cleared PHASE / BDF 321 / 12 The stored caller values remain, but mask zero restores netlist precedence Run the complete Python comparison Run this from the extracted teaching folder after assigning the three variables above. results-first must not already exist. The helper intentionally refuses a reused output directory; choose a fresh destination after inspecting an interrupted attempt. The script asserts precedence and origins before executing. It checks the completed record and committed file, parses raw-SI CSV, checks finite values and 21 aligned samples, and compares the teaching resistor with 1 mV and 20 microamps using 1e-9 relative plus 1e-15 absolute tolerance. These are synthetic transfer checks, not general device-accuracy limits. The PHASE/BDF cases store zero voltage in the initial row of this example; their positive-time voltages are 1 mV and their current is 20 microamps throughout. The VOLTAGE/TRAP case directly stores 1 mV in every row. The checker distinguishes that initial representation rather than silently dropping the first row. Extract both supplied files together into a new writable teaching folder. Assign $Python, $ModuleDir and $Licence to the intended compatible interpreter, coherent distribution and issued JoSIM licence path. Run the exact PowerShell block from that folder with a new results-first destination. Read summary.json and all three current CSVs; inspect planned origins and the completed committed-file receipts. If a check fails, retain diagnostics and partial output, correct the cause and construct a fresh plan in a new destination. & $Python -B .\\run_precedence.py --module-dir $ModuleDir --licence $Licence --output-root .\\results-first\nif ($LASTEXITCODE -ne 0) { throw 'Runtime precedence check failed; inspect the first diagnostic and retained outputs.' } Save run_precedence.py \"\"\"Compare deck precedence, selected overrides and a cleared override mask.\"\"\"\nimport argparse\nimport csv\nimport hashlib\nimport json\nimport math\nimport os\nfrom pathlib import Path\nimport sys\n\nMAX_SEED = 18446744073709551615\n\n\ndef sha(path):\n    return hashlib.sha256(path.read_bytes()).hexdigest()\n\n\ndef load_module(directory):\n    # Change only this process. Keep the DLL-directory handle alive until exit.\n    handles = []\n    if directory:\n        directory = directory.resolve(strict=True)\n        if sys.platform == 'win32':\n            handles.append(os.add_dll_directory(str(directory)))\n        sys.path.insert(0, str(directory))\n    import josimpro as jp\n    return jp, handles\n\n\ndef build_plan(jp, source, directory, mode, events):\n    rt = jp.Runtime()\n    rt.workingDir = str(directory)\n    rt.inputFile = str(source)\n    rt.analysisType = 1\n    rt.integrationMethod = 1\n    rt.seed = MAX_SEED\n    rt.outputPrecision = 17\n    rt.tStep = 4e-12\n    rt.tStop = 12e-12\n    rt.progressFn = lambda stage, current, total: events.append(('progress', stage))\n    rt.progressDetailFn = lambda kind, text: events.append(('detail', kind))\n    selected = jp.OVERRIDE_ANALYSIS | jp.OVERRIDE_INTEGRATION | jp.OVERRIDE_SEED | jp.OVERRIDE_PRECISION\n    if mode in ('override', 'cleared'):\n        rt.override_mask = selected\n    if mode == 'cleared':\n        rt.override_mask = 0\n    rt.set_output_file(mode + '.csv')\n    inp = jp.Input()\n    inp.runtime = rt\n    inp.read_input()\n    inp.parse_input()\n    return rt, inp, jp.AnalysisJobs(inp, True)\n\n\ndef checked_run(jp, source, directory, mode):\n    events = []\n    rt, inp, jobs = build_plan(jp, source, directory, mode, events)\n    snapshot_text = jobs.effective_settings_json(0)\n    before = len(events)\n    assert jobs.effective_settings_json(0) == snapshot_text\n    assert len(events) == before, 'Inspecting cached settings invoked callbacks'\n    preview = json.loads(snapshot_text)\n    explicit = mode == 'override'\n    expected = {'analysisType': int(explicit), 'integrationMethod': int(explicit),\n                'seed': MAX_SEED if explicit else 321,\n                'outputPrecision': 17 if explicit else 12,\n                'compressedOutput': False, 'variableStepEnabled': False,\n                'newtonJJEnabled': False}\n    assert preview['schema'] == 'josim-run-configuration/1'\n    for field, value in expected.items():\n        assert preview[field] == value, (mode, field, preview[field])\n        origin = 'run_override' if explicit and field in ('analysisType', 'integrationMethod', 'seed', 'outputPrecision') else 'netlist'\n        assert preview['setting_origins'][field]['origin'] == origin\n    assert preview['tStep'] == 1e-12 and preview['tStop'] == 20e-12\n    assert preview['outputs'][0]['format'] == 'CSV'\n    destination = directory / (mode + '.csv')\n    assert Path(preview['outputs'][0]['path']) == destination\n    assert not destination.exists(), 'Preview unexpectedly wrote numerical output'\n    (directory / (mode + '-planned.json')).write_text(snapshot_text + '\\n', encoding='utf-8')\n    jobs.run()\n    record = json.loads(jobs.result_record_json(0))\n    assert record['schema'] == 'josim-run-record/1' and record['status'] == 'succeeded'\n    assert record['completion'] == 'completed' and record['files'][0]['committed']\n    assert record['seed'] == expected['seed']\n    with destination.open(encoding='utf-8-sig', newline='') as stream:\n        rows = list(csv.reader(stream))\n    assert rows[0] == ['time', 'V(IN)', 'I(R1)'] and len(rows) == 22\n    values = [[float(v) for v in row] for row in rows[1:]]\n    assert all(len(row) == 3 and all(math.isfinite(v) for v in row) for row in values)\n    for index, (time, voltage, current) in enumerate(values):\n        assert math.isclose(time, index * 1e-12, rel_tol=1e-12, abs_tol=1e-24)\n        # PHASE reconstructs voltage from phase differences. Its first stored\n        # voltage is zero here; compare the Ohm-law voltage at positive times.\n        assert math.isclose(voltage, 0.0 if index == 0 and not explicit else 0.001, rel_tol=1e-9, abs_tol=1e-15)\n        assert math.isclose(current, 0.001 / 50, rel_tol=1e-9, abs_tol=1e-15)\n    assert len(jobs.results[0].axis) == 21 and len(jobs.results[0].traces) == 2\n    (directory / (mode + '-record.json')).write_text(jobs.result_record_json(0) + '\\n', encoding='utf-8')\n    return {'resolved': expected, 'rows': len(values), 'committed': True,\n            'callbacks_observed': bool(events), 'csv_sha256': sha(destination)}\n\n\ndef main():\n    parser = argparse.ArgumentParser(description=__doc__)\n    parser.add_argument('--module-dir', type=Path, help='Directory of a matching module/core distribution')\n    parser.add_argument('--licence', type=Path, help='Existing issued JoSIM licence file; never its contents')\n    parser.add_argument('--output-root', type=Path, required=True, help='New directory; reused paths are refused')\n    args = parser.parse_args()\n    source = Path(__file__).resolve().with_name('precedence.cir')\n    original = sha(source)\n    output = args.output_root.resolve()\n    output.mkdir(parents=True, exist_ok=False)\n    jp, handles = load_module(args.module_dir)\n    if args.licence:\n        jp.Settings.license = str(args.licence.resolve(strict=True))\n    jp.Settings.minOutput = True\n    identity = json.loads(jp.core_identity_json())\n    assert identity['version'] == '2.9.0', 'Use the qualified matching 2.9 distribution'\n    results = {mode: checked_run(jp, source, output, mode) for mode in ('deck', 'override', 'cleared')}\n    assert sha(source) == original\n    summary = {'status': 'passed', 'scope': 'Synthetic Windows review example; not general accuracy or release qualification',\n               'source_sha256': original, 'core_version': identity['version'],\n               'core_sha256': identity['sha256'], 'cases': results}\n    (output / 'summary.json').write_text(json.dumps(summary, indent=2) + '\\n', encoding='utf-8')\n    print(json.dumps(summary, indent=2))\n    # handles deliberately remain live through all native calls.\n    assert isinstance(handles, list)\n\n\nif __name__ == '__main__':\n    main() Inspect a fresh plan and its actual receipt Set workingDir and inputFile, then attach Runtime to an empty Input before read_input() and parse_input(). Input(\"file.cir\") reads and parses immediately. Construct a fresh single-use AnalysisJobs plan after source/settings changes. effective_settings_json(index) is cached josim-run-configuration/1 JSON. Inspect requested_defaults, resolved top-level values, setting_origins, source locations, override_mask, seed and outputs. Repeated inspection does not call progress callbacks or write numerical output. Later edits to the caller Runtime do not mutate the existing plan. After run() returns, inspect result_record_json(index): status=succeeded, completion=completed and the intended files[].committed must agree with fresh numerical data. These receipts describe calculation/publication separately. Calling run() twice on the same plan is rejected. Keep copied callback data short and inspect the plan only before or after run(). The run releases the GIL and callbacks may run synchronously on its worker. Use request_abort() for cancellation; do not query or mutate an active plan. Only callback lifetime, real callback observation and cached-preview behaviour were exercised here; concurrent cancellation/exception paths still need dedicated checks.  Keep output routing and input protection explicit set_output_file resolves a relative destination against workingDir at setter time, not when the plan later runs. Set workingDir first. Changing it later does not move that already selected output. Empty text clears the primary destination and restores subsequent .FILE routing. The checked runtime rejects writing over the source and over a hardlink alias of it. Invalid timing leaves an existing destination unchanged; a successful publication replaces the existing output. Preview alone neither writes nor reserves a future destination. Preserve source/include/model identity and construct a fresh plan after changes. The separate all-seven-bit control resolves every origin to run_override and runs PHASE+BDF variable-step mode with JJ Newton enabled and gzip output. This confirms the control/receipt route on a resistor; it does not qualify nonlinear junction convergence or all variable-step circuits. VOLTAGE+TRAP with variable-step enabled is rejected through DiagnosticError with messages, category and cancelled state.  Recognise the two retained discrepancies KB-RUNTIME-001: explicit seed=0 with OVERRIDE_SEED selects a nonzero seed, and the cached preview matches the completed record, but seed_mode reports fixed in this candidate. requested_defaults.seed remains 0 and its origin is run_override. Preserve both the request and resolved seed; do not infer that the caller chose a fixed seed from this label alone. Automatic-seed uniqueness/quality is outside these checks. KB-TRAP-001: keeping PHASE and overriding only integration to TRAP on this constant 1 mV / 50 ohm deck produces alternating 0 and 40 microamp current while positive-time voltage remains 1 mV. A separate CLI run reproduces it at matching output precision. The ideal branch current is 20 microamps. Both runs report success, so success metadata alone does not qualify the values. The complete accepted example uses PHASE/BDF and VOLTAGE/TRAP with independent resistor checks. Treat the PHASE/TRAP counterexample as unresolved; do not generalise either result to all TRAP circuits or silently change a real circuit’s formulation. Root cause, startup/timestep sensitivity, other platforms and final packages remain to be investigated.  Check the result Expect summary.json with status passed and three committed 21-row CSVs. Retain the exact source bytes, requested/resolved settings, actual module/core identity and completed receipts. A partial directory, an old output or a finite plot does not establish success.  If the problem remains Check the first Python/native diagnostic, compatible interpreter/module/core and actual DLL dependencies. When a setter appears ineffective, inspect the deck option and corresponding override bit. For a failed run preserve existing results, correct the input/destination and construct a fresh plan in a new output directory. Do not adjust solver tolerances to hide a precedence or dependency problem. ","id":"josim-runtime-precedence","keywords":"python runtime settings override mask precedence defaults analysis type effective_settings_json requested_defaults setting_origins cached preview uint64 seed 18446744073709551615 automatic seed fixed label relative set_output_file setter time output source hardlink collision PHASE TRAP resistor current alternates 0 40 microamps Python MSVCP140 old compiler DLL search crash runtime dependency DiagnosticError messages category cancelled callbacks GIL","kind":"How to","title":"Understand Python Runtime defaults and netlist overrides","product":"JoSIM-Pro"},"version":"2.9.0 release target; matching isolated Windows Python review module/core","id":"josim-runtime-precedence","related":["/knowledge-base/josim-python-first-run","/knowledge-base/josim-noise-settings","/knowledge-base/josim-variable-step-lines","/knowledge-base/josim-api-output"],"downloads":[{"url":"/_functions/kbExample?name=josim-runtime-precedence.zip","scope":"Exact checked input files plus instructions; final-release/platform applicability remains pending.","files":["precedence.cir","run_precedence.py","README.txt"],"id":"josim-runtime-precedence","requires":["Matching licensed JoSIM 2.9 Windows Python/core distribution","Compatible Python ABI/architecture and new writable output directory"],"title":"Complete Python Runtime precedence comparison"}],"publication_status":"published","numerical_output":null,"provenance":{"execution_checks":[{"routes":["python"],"scope":"Actual matching isolated Windows 2.9 CPython 3.13 Runtime contract and three synthetic precedence runs; no GUI, final package, other platform, stochastic ensemble or general numerical accuracy qualification.","result":"passed","articles":["josim-runtime-precedence"],"purpose":"actual-python-runtime-precedence-plan-output-protection-and-counterexamples","version":"Matching isolated Windows current-source JoSIM-Pro 2.9 core/module, CPython 3.13.11","id":"VAL-064","records":["27 independent client/API/artifact checks"],"limit":"No GUI, stochastic ensemble, all Python versions, final package/platform or general numerical accuracy acceptance. KB-RUNTIME-001 and KB-TRAP-001 remain open.","observed":{"trace_names":["V(IN)","I(R1)"],"timing_stop_s":2e-11,"rows_per_case":21,"intermediate_phase_trap":{"ideal_resistor_current_A":0.00002,"current_samples_A":[0,0.00004,0,0.00004],"status":"succeeded","rows":21,"voltage_samples_V":[0,0.001,0.001,0.001]},"negative_case_count":6,"timing_step_s":1e-12,"automatic_seed_preview":{"origin":{"origin":"run_override"},"requested_seed":0,"seed":1793774265,"seed_mode":"fixed"},"deck_seed":321,"override_seed":"18446744073709551615"}}],"figure_evidence":[],"review_notes":["Actual matching module/core CPython 3.13.11 checks replace the earlier manual-only disposition. Full package/platform release applicability remains open.","The private harness initially loaded an old C++ runtime from the compiler tools directory. Restricting DLL search to the coherent review distribution, with local OpenMP, resolves that setup failure; installed files were not changed.","KB-RUNTIME-001 tracks the automatic-seed metadata label. KB-TRAP-001 retains the separately reproduced PHASE/TRAP constant-source current discrepancy; no product repair or broad mode acceptance.","The frozen module/input sources precede the separately reviewed maintained UTF-8 path changes. This ASCII-path run does not qualify those later changes or Unicode paths."],"scope":"Recorded inputs/builds only. Complete walkthrough and final-package acceptance remain separate.","verification_requirements":{"gui_method":"not-required-for-this-answer","status":"review-incomplete","illustrations":"not-required-for-this-answer","required":["technical-review","release-applicability","execution"],"legacy_walkthrough_field":"pending retained; not evidence of a complete scenario"},"sources":[{"id":"josim-pro:docs/manual_source/sections/python.tex","section":"Python module availability, Settings, Runtime, override/destination contract and callback/identity limits"},{"id":"validation:runtime-precedence-20261104","section":"VAL-064: 27 actual client/API/artifact checks; separate CLI counterexample"}]},"integer_encoding":"Integers outside the JavaScript safe-integer range are exact decimal strings, not floating-point numbers.","title":"Understand Python Runtime defaults and netlist overrides","type":"How to","markdown_url":"/_functions/kbResource?path=markdown%2Fjosim-runtime-precedence.md","summary":"Inspect the resolved plan, choose explicit overrides only where intended, and verify fresh numerical output with a complete three-case Python example.","product":"JoSIM-Pro"}