fix: persist incident isolation and atomically publish netlist evidence
Core regression / Python core, intervention UI and release configuration (push) Successful in 4m35s
Core regression / JavaScript syntax (push) Successful in 6s
Core regression / Python core, intervention UI and release configuration (pull_request) Successful in 3m54s
Core regression / JavaScript syntax (pull_request) Successful in 4s
Core regression / Python core, intervention UI and release configuration (push) Successful in 4m35s
Core regression / JavaScript syntax (push) Successful in 6s
Core regression / Python core, intervention UI and release configuration (pull_request) Successful in 3m54s
Core regression / JavaScript syntax (pull_request) Successful in 4s
This commit is contained in:
1 parent
a0f0a4b232
commit
cffef93b37
42 files changed
+2291
-29
No files matched your search
@@ -50,6 +50,7 @@ def retained_bom_rows(pending, existing_rows):
|
||||
|
||||
|
||||
def pending_requests(store, task_id):
|
||||
"""Read frozen BOM requests with their original Excel row and source hash."""
|
||||
with store._lock:
|
||||
row = store._connection.execute('SELECT payload_json FROM pending_bom WHERE task_id=?', (task_id,)).fetchone()
|
||||
if row is None:
|
||||
@@ -66,6 +67,7 @@ def _template_record(record):
|
||||
|
||||
|
||||
def resolution_binding(store, task_id):
|
||||
"""Return the confirmed/resolved plan hashes, or None before resolution."""
|
||||
with store._lock:
|
||||
row = store._connection.execute('SELECT confirmed_hash, resolved_hash FROM bom_resolution WHERE task_id=?',
|
||||
(task_id,)).fetchone()
|
||||
@@ -73,6 +75,7 @@ def resolution_binding(store, task_id):
|
||||
|
||||
|
||||
def import_drafts(service, task_id, sources, *, stop_event=None, on_progress=None, on_phase=None, allow_partial=False):
|
||||
"""Persist routed spreadsheet requests without opening CAD or resolving parts."""
|
||||
rows = load_sources(sources, stop_event=stop_event, on_progress=on_progress, allow_partial=allow_partial)
|
||||
scope = _scope(service._store, task_id)
|
||||
paths = tuple(project.path for _, project in scope)
|
||||
@@ -131,6 +134,7 @@ def import_drafts(service, task_id, sources, *, stop_event=None, on_progress=Non
|
||||
|
||||
|
||||
def resolve_pending(service, task_id, *, stop_event=None, on_progress=None, runtime=None):
|
||||
"""Resolve frozen requests through native inventory; retain errors and source rows."""
|
||||
pending = pending_requests(service._store, task_id)
|
||||
if not pending:
|
||||
return service._store.list_target_plan(task_id)
|
||||
|
||||
@@ -7,6 +7,7 @@ _UNCERTAIN_SCOPES = []
|
||||
|
||||
|
||||
class OwnedCliScope:
|
||||
"""Own hidden CLI process Jobs and retain any unconfirmed cleanup for retry."""
|
||||
def __init__(self, name=None, *, enabled=True, api=None):
|
||||
self._api = api
|
||||
self._processes = []
|
||||
@@ -22,12 +23,14 @@ class OwnedCliScope:
|
||||
self.close()
|
||||
|
||||
def start_process(self, command, *, cwd=None, env=None, stdout=None, stderr=None):
|
||||
"""Start and track a hidden CLI on Default without creating a desktop."""
|
||||
process = self._api.create_process(command, 'winsta0\\Default', cwd, env,
|
||||
stdout=stdout, stderr=stderr)
|
||||
self._processes.append(process)
|
||||
return process
|
||||
|
||||
def close(self):
|
||||
"""Close owned Jobs; report inventory_cleanup if any release is unconfirmed."""
|
||||
errors, records = [], []
|
||||
for process in self._processes:
|
||||
try:
|
||||
@@ -48,11 +51,13 @@ class OwnedCliScope:
|
||||
|
||||
|
||||
def installation_root():
|
||||
"""Locate the installed Mentor tree from its registered Designer executable."""
|
||||
from .isolated_cad import _designer_executable
|
||||
return _designer_executable().parents[3]
|
||||
|
||||
|
||||
def environment(root):
|
||||
"""Build a child-only Mentor CLI environment without changing the parent PATH."""
|
||||
import os
|
||||
root = str(root)
|
||||
env = dict(os.environ, SDD_HOME=root, SDD_PLATFORM='win32')
|
||||
|
||||
@@ -11,6 +11,7 @@ import tempfile
|
||||
import time
|
||||
|
||||
from .errors import TaskCenterError
|
||||
from .batch_resources import write_record
|
||||
from .native_inventory import _hash, _project_options
|
||||
from .native_inventory_protocol import _require_report, read_native_text
|
||||
from .native_cli import OwnedCliScope, environment, installation_root
|
||||
@@ -20,11 +21,11 @@ from .path_access import canonical_path, internal_path
|
||||
_VALUE_COVERAGE = 'ASCII serializes an absent Value as empty text; empty text does not prove attribute presence.'
|
||||
|
||||
|
||||
def _write_json(path, record):
|
||||
internal_path(path).write_text(json.dumps(record, ensure_ascii=False, indent=2), encoding='utf-8')
|
||||
|
||||
|
||||
def capture_project(project: Path, destination: Path) -> dict:
|
||||
"""Copy saved project inputs into a new external directory and bind their hashes.
|
||||
|
||||
Source or configuration changes raise; an existing destination is never reused.
|
||||
"""
|
||||
project = canonical_path(internal_path(project), strict=True)
|
||||
text, block, snapshot, database = _project_options(project)
|
||||
destination = canonical_path(destination)
|
||||
@@ -56,7 +57,7 @@ def capture_project(project: Path, destination: Path) -> dict:
|
||||
'database_path': str(destination / 'database/icdb.dat'), 'source_hashes': hashes,
|
||||
'capture_hashes': {relative: _hash(destination / relative) for relative in files},
|
||||
'manifest_path': str(destination / 'capture.json')}
|
||||
_write_json(destination / 'capture.json', record)
|
||||
write_record(destination / 'capture.json', record)
|
||||
return record
|
||||
|
||||
|
||||
@@ -272,6 +273,11 @@ def _parse_keyin(path):
|
||||
|
||||
|
||||
def read_graph(ascii_path, keyin_path, *, hierarchy_path=None, root_block=None):
|
||||
"""Read and cross-check native ASCII/Keyin components and physical connections.
|
||||
|
||||
Optional hierarchy_path/root_block bind every expanded instance and hierarchy
|
||||
boundary; incomplete or ambiguous coverage raises ValueError.
|
||||
"""
|
||||
boundaries = _check_hierarchy_graph(hierarchy_path, None, root_block)[1] if hierarchy_path is not None else ()
|
||||
components, nets = _parse_ascii(ascii_path, hierarchy_boundaries=boundaries)
|
||||
keyin, parts = _parse_keyin(keyin_path)
|
||||
@@ -360,6 +366,12 @@ def _check_hierarchy_graph(path, graph, root_block):
|
||||
|
||||
|
||||
def export_netlist(capture: dict, output: Path, *, stop_event=None) -> dict:
|
||||
"""Export immutable captured inputs with owned native CLI processes into output.
|
||||
|
||||
Return success/failed/cancelled with completeness, outputs and diagnostics;
|
||||
stop_event cancels cooperatively. coverage_limits states known format limits.
|
||||
Evidence publication errors can propagate; old reports remain intact.
|
||||
"""
|
||||
output = Path(output)
|
||||
result = {'status': 'failed', 'complete': False, 'capture': capture, 'outputs': {}, 'runs': [],
|
||||
'coverage_limits': [_VALUE_COVERAGE]}
|
||||
@@ -412,11 +424,11 @@ def export_netlist(capture: dict, output: Path, *, stop_event=None) -> dict:
|
||||
result['graph'] = read_graph(Path(result['outputs']['effective']), Path(result['outputs']['keyin']),
|
||||
hierarchy_path=Path(result['outputs']['hier']), root_block=capture['root_block'])
|
||||
result.update(status='success', complete=True)
|
||||
_write_json(output / 'graph.json', result['graph'])
|
||||
write_record(output / 'graph.json', result['graph'])
|
||||
result['outputs']['graph'] = str(output / 'graph.json')
|
||||
except Exception as error:
|
||||
result.update(status='cancelled' if isinstance(error, TaskCenterError) and error.code == 'operation_cancelled' else 'failed', reason=str(error))
|
||||
_write_json(output / 'netlist.json', result)
|
||||
write_record(output / 'netlist.json', result)
|
||||
return result
|
||||
|
||||
|
||||
@@ -455,6 +467,11 @@ def _connections(graph):
|
||||
|
||||
|
||||
def compare_netlists(before: dict, after: dict, *, expected_changes=None, expected_symbols=None) -> dict:
|
||||
"""Compare complete nonempty exports, allowing only declared attribute/symbol changes.
|
||||
|
||||
Return verified/different/unavailable and differences; coverage_limits records
|
||||
format limits, including that empty Value text cannot prove attribute presence.
|
||||
"""
|
||||
for result in (before, after):
|
||||
graph = result.get('graph', {})
|
||||
if result.get('status') != 'success' or result.get('complete') is not True or not graph.get('components') or not graph.get('nets'):
|
||||
|
||||
@@ -214,6 +214,11 @@ class NetlistVerification:
|
||||
return self
|
||||
|
||||
def before_task(self, child, task_id, *, existing_only=False):
|
||||
"""Freeze one project's original inputs/plan and schedule its baseline export.
|
||||
|
||||
existing_only loads an existing capture/plan pair without creating one;
|
||||
resume retains that baseline. Scope or capture errors remain visible.
|
||||
"""
|
||||
if task_id in self.tasks:
|
||||
return
|
||||
directory = self.root / 'tasks' / task_id / 'netlist-checks' / self.run_id
|
||||
@@ -271,6 +276,12 @@ class NetlistVerification:
|
||||
record.update(status='unavailable', reason=str(error))
|
||||
|
||||
def after_task(self, task_id, *, execution_state='completed', execution_summary=None, refresh=False):
|
||||
"""Capture saved post-execution inputs and schedule an independent export.
|
||||
|
||||
Recheck the single-project scope; refresh captures a newer retry outcome.
|
||||
Execution state/counts remain separate from graph acceptance; a completed
|
||||
rule with zero saved items needs no comparison after scope is verified.
|
||||
"""
|
||||
record = self.tasks.get(task_id)
|
||||
if record is None:
|
||||
return
|
||||
@@ -350,6 +361,11 @@ class NetlistVerification:
|
||||
return expected
|
||||
|
||||
def finish(self):
|
||||
"""Wait for exports and persist reports bound to this run/task/project evidence.
|
||||
|
||||
Repeated calls retain collected results. Later pause signals do not erase
|
||||
complete comparisons; cancelled exports and incomplete execution cannot pass.
|
||||
"""
|
||||
for task_id, record in self.tasks.items():
|
||||
if task_id in self.results:
|
||||
continue
|
||||
|
||||
Reference in new issue
Block a user