rocket-engine 0.0.2b1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rocket_engine/__init__.py +8 -0
- rocket_engine/__main__.py +12 -0
- rocket_engine/adapters/README.md +54 -0
- rocket_engine/adapters/__init__.py +7 -0
- rocket_engine/adapters/api.py +39 -0
- rocket_engine/adapters/base.py +46 -0
- rocket_engine/adapters/cace/__init__.py +163 -0
- rocket_engine/adapters/circulax/README.md +10 -0
- rocket_engine/adapters/circulax/__init__.py +112 -0
- rocket_engine/adapters/circulax/_driver.py +190 -0
- rocket_engine/adapters/circulax/adapter.py +538 -0
- rocket_engine/adapters/circulax/results.py +291 -0
- rocket_engine/adapters/cli/README.md +34 -0
- rocket_engine/adapters/cli/__init__.py +305 -0
- rocket_engine/adapters/connectivity/__init__.py +196 -0
- rocket_engine/adapters/connectivity/results.py +214 -0
- rocket_engine/adapters/cosim/README.md +9 -0
- rocket_engine/adapters/cosim/__init__.py +1390 -0
- rocket_engine/adapters/cosim/results.py +214 -0
- rocket_engine/adapters/devsim/__init__.py +171 -0
- rocket_engine/adapters/digital_flow/README.md +9 -0
- rocket_engine/adapters/digital_flow/__init__.py +1121 -0
- rocket_engine/adapters/digital_flow/results.py +227 -0
- rocket_engine/adapters/digital_flow/state.py +462 -0
- rocket_engine/adapters/drc/README.klayout.md +7 -0
- rocket_engine/adapters/drc/README.md +7 -0
- rocket_engine/adapters/drc/__init__.py +1 -0
- rocket_engine/adapters/drc/klayout.py +952 -0
- rocket_engine/adapters/drc/magic.py +287 -0
- rocket_engine/adapters/drc/results.py +184 -0
- rocket_engine/adapters/drc/results_kl.py +188 -0
- rocket_engine/adapters/elmer/__init__.py +163 -0
- rocket_engine/adapters/envelope.py +120 -0
- rocket_engine/adapters/equivalence/__init__.py +156 -0
- rocket_engine/adapters/errors.py +181 -0
- rocket_engine/adapters/extract_magic/README.md +15 -0
- rocket_engine/adapters/extract_magic/__init__.py +425 -0
- rocket_engine/adapters/extract_magic/results.py +209 -0
- rocket_engine/adapters/formal_sby/README.md +7 -0
- rocket_engine/adapters/formal_sby/__init__.py +773 -0
- rocket_engine/adapters/formal_sby/formal_edge.py +195 -0
- rocket_engine/adapters/formal_sby/results.py +185 -0
- rocket_engine/adapters/gdsfactory/__init__.py +194 -0
- rocket_engine/adapters/gdsfactory/_driver.py +459 -0
- rocket_engine/adapters/gdsfactory/adapter.py +609 -0
- rocket_engine/adapters/gdsfactory/results.py +181 -0
- rocket_engine/adapters/hdl_sim/README.md +7 -0
- rocket_engine/adapters/hdl_sim/__init__.py +369 -0
- rocket_engine/adapters/hdl_sim/ghdl.py +155 -0
- rocket_engine/adapters/hdl_sim/results.py +178 -0
- rocket_engine/adapters/hdl_sim/verilator.py +167 -0
- rocket_engine/adapters/http/README.md +15 -0
- rocket_engine/adapters/http/__init__.py +458 -0
- rocket_engine/adapters/http/events.py +63 -0
- rocket_engine/adapters/ipc/README.md +9 -0
- rocket_engine/adapters/ipc/__init__.py +111 -0
- rocket_engine/adapters/lvs_netgen/README.md +20 -0
- rocket_engine/adapters/lvs_netgen/__init__.py +889 -0
- rocket_engine/adapters/lvs_netgen/results.py +168 -0
- rocket_engine/adapters/mcp/README.md +19 -0
- rocket_engine/adapters/mcp/__init__.py +85 -0
- rocket_engine/adapters/mcp/api-schema.json +6107 -0
- rocket_engine/adapters/mcp/pull.py +246 -0
- rocket_engine/adapters/mcp/server.py +794 -0
- rocket_engine/adapters/meep/__init__.py +167 -0
- rocket_engine/adapters/meow/README.md +7 -0
- rocket_engine/adapters/meow/__init__.py +190 -0
- rocket_engine/adapters/meow/_driver.py +227 -0
- rocket_engine/adapters/meow/_envelope.py +108 -0
- rocket_engine/adapters/meow/adapter.py +491 -0
- rocket_engine/adapters/meow/results.py +218 -0
- rocket_engine/adapters/mutation/__init__.py +192 -0
- rocket_engine/adapters/ngspice/README.md +28 -0
- rocket_engine/adapters/ngspice/__init__.py +627 -0
- rocket_engine/adapters/ngspice/results.py +215 -0
- rocket_engine/adapters/postlayout/README.md +28 -0
- rocket_engine/adapters/postlayout/__init__.py +17 -0
- rocket_engine/adapters/postlayout/adapter.py +1062 -0
- rocket_engine/adapters/postlayout/results.py +330 -0
- rocket_engine/adapters/postlayout/translate.py +71 -0
- rocket_engine/adapters/profile.py +220 -0
- rocket_engine/adapters/sax/README.md +23 -0
- rocket_engine/adapters/sax/__init__.py +516 -0
- rocket_engine/adapters/sax/_driver.py +148 -0
- rocket_engine/adapters/sax/results.py +291 -0
- rocket_engine/adapters/stdio_console.py +1151 -0
- rocket_engine/adapters/syntax/README.md +5 -0
- rocket_engine/adapters/syntax/__init__.py +366 -0
- rocket_engine/adapters/syntax/results.py +181 -0
- rocket_engine/adapters/synth_yosys/README.md +7 -0
- rocket_engine/adapters/synth_yosys/__init__.py +655 -0
- rocket_engine/adapters/synth_yosys/amaranth.py +120 -0
- rocket_engine/adapters/synth_yosys/ghdl.py +128 -0
- rocket_engine/adapters/synth_yosys/results.py +173 -0
- rocket_engine/adapters/timing_sta/README.md +9 -0
- rocket_engine/adapters/timing_sta/__init__.py +726 -0
- rocket_engine/adapters/view_sync/__init__.py +185 -0
- rocket_engine/adapters/view_sync/results.py +189 -0
- rocket_engine/adapters/vlsir/__init__.py +142 -0
- rocket_engine/adapters/xschem/__init__.py +440 -0
- rocket_engine/adapters/xschem/deck.py +266 -0
- rocket_engine/clients/__init__.py +5 -0
- rocket_engine/clients/runtime.py +255 -0
- rocket_engine/composition.py +2279 -0
- rocket_engine/execution/README.md +30 -0
- rocket_engine/execution/__init__.py +150 -0
- rocket_engine/execution/apig/__init__.py +1 -0
- rocket_engine/execution/apig/pool.py +463 -0
- rocket_engine/execution/apig/submit.py +124 -0
- rocket_engine/execution/block_runs_scope.py +479 -0
- rocket_engine/execution/coalesce.py +414 -0
- rocket_engine/execution/console/__init__.py +1 -0
- rocket_engine/execution/console/apply_session.py +318 -0
- rocket_engine/execution/console/lifecycle.py +265 -0
- rocket_engine/execution/dispatch.py +205 -0
- rocket_engine/execution/errors.py +31 -0
- rocket_engine/execution/ports.py +797 -0
- rocket_engine/execution/pyexec/__init__.py +1 -0
- rocket_engine/execution/pyexec/apply_context.py +547 -0
- rocket_engine/execution/pyexec/approvals.py +173 -0
- rocket_engine/execution/pyexec/runner.py +404 -0
- rocket_engine/execution/pyexec/support.py +464 -0
- rocket_engine/execution/python_exec.py +897 -0
- rocket_engine/execution/queue.py +85 -0
- rocket_engine/execution/replay_safe.py +601 -0
- rocket_engine/execution/routing/__init__.py +1 -0
- rocket_engine/execution/routing/calls.py +364 -0
- rocket_engine/execution/routing/namespace.py +785 -0
- rocket_engine/execution/routing/ports.py +102 -0
- rocket_engine/execution/routing/tools.py +346 -0
- rocket_engine/execution/runner.py +311 -0
- rocket_engine/execution/runtime.py +1149 -0
- rocket_engine/execution/service.py +279 -0
- rocket_engine/execution/worker.py +464 -0
- rocket_engine/interfaces/README.md +26 -0
- rocket_engine/interfaces/__init__.py +58 -0
- rocket_engine/interfaces/apig_assets.py +407 -0
- rocket_engine/interfaces/celllink.py +461 -0
- rocket_engine/interfaces/documents.py +92 -0
- rocket_engine/interfaces/envelopes.py +131 -0
- rocket_engine/interfaces/errors.py +16 -0
- rocket_engine/interfaces/layout.py +410 -0
- rocket_engine/interfaces/layout_schema.yaml +278 -0
- rocket_engine/interfaces/paths.py +223 -0
- rocket_engine/interfaces/pdks.py +550 -0
- rocket_engine/interfaces/ports.py +72 -0
- rocket_engine/interfaces/references.py +115 -0
- rocket_engine/interfaces/refs.py +85 -0
- rocket_engine/interfaces/runparams.py +304 -0
- rocket_engine/interfaces/setup.py +552 -0
- rocket_engine/interfaces/setup_catalogue.yaml +243 -0
- rocket_engine/interfaces/setup_probes.py +66 -0
- rocket_engine/interfaces/vocabulary.py +58 -0
- rocket_engine/interfaces/yaml_dump.py +31 -0
- rocket_engine/library/README.md +22 -0
- rocket_engine/library/__init__.py +13 -0
- rocket_engine/library/apig_catalog.py +371 -0
- rocket_engine/library/catalog.py +185 -0
- rocket_engine/library/errors.py +16 -0
- rocket_engine/mutate/__init__.py +776 -0
- rocket_engine/mutate/operators.py +700 -0
- rocket_engine/ops/__init__.py +1 -0
- rocket_engine/ops/deferred.py +279 -0
- rocket_engine/ops/editors.py +404 -0
- rocket_engine/ops/evidence.py +194 -0
- rocket_engine/ops/gates.py +262 -0
- rocket_engine/ops/ports.py +76 -0
- rocket_engine/ops/queries.py +417 -0
- rocket_engine/ops/runs.py +553 -0
- rocket_engine/ops/submit.py +614 -0
- rocket_engine/project/README.md +27 -0
- rocket_engine/project/__init__.py +6 -0
- rocket_engine/project/canvas/__init__.py +55 -0
- rocket_engine/project/canvas/compile.py +109 -0
- rocket_engine/project/canvas/integrate.py +48 -0
- rocket_engine/project/canvas/schema.py +241 -0
- rocket_engine/project/canvas/templates.py +46 -0
- rocket_engine/project/canvas/validate.py +603 -0
- rocket_engine/project/edit/__init__.py +5 -0
- rocket_engine/project/edit/cas.py +87 -0
- rocket_engine/project/edit/transactions.py +282 -0
- rocket_engine/project/errors.py +16 -0
- rocket_engine/project/frontend13.py +685 -0
- rocket_engine/project/geometry/__init__.py +23 -0
- rocket_engine/project/geometry/ops.py +451 -0
- rocket_engine/project/geometry/snap.py +103 -0
- rocket_engine/project/ip/__init__.py +1 -0
- rocket_engine/project/ip/blocks.py +195 -0
- rocket_engine/project/ip/entry.schema.json +78 -0
- rocket_engine/project/ip/lifecycle.py +402 -0
- rocket_engine/project/ip/verbs.py +123 -0
- rocket_engine/project/layers/__init__.py +6 -0
- rocket_engine/project/layers/bindings.py +115 -0
- rocket_engine/project/layers/catalog.py +228 -0
- rocket_engine/project/layers/presets.py +43 -0
- rocket_engine/project/ledger/__init__.py +1 -0
- rocket_engine/project/ledger/docs.py +167 -0
- rocket_engine/project/ledger/entities.py +176 -0
- rocket_engine/project/ledger/events.py +29 -0
- rocket_engine/project/ledger/runs.py +257 -0
- rocket_engine/project/ledger/shared.py +174 -0
- rocket_engine/project/ledger/snapshots.py +385 -0
- rocket_engine/project/ledger/wires.py +552 -0
- rocket_engine/project/process/__init__.py +14 -0
- rocket_engine/project/process/model.py +193 -0
- rocket_engine/project/process/recipes.py +121 -0
- rocket_engine/project/schematic/__init__.py +1 -0
- rocket_engine/project/schematic/hierarchy.py +312 -0
- rocket_engine/project/schematic/instances.py +393 -0
- rocket_engine/project/schematic/sheets.py +198 -0
- rocket_engine/project/service.py +2941 -0
- rocket_engine/project/symbols/__init__.py +1 -0
- rocket_engine/project/symbols/cells.py +324 -0
- rocket_engine/project/symbols/linkage.py +356 -0
- rocket_engine/project/symbols/symbols.py +352 -0
- rocket_engine/project/templates/__init__.py +303 -0
- rocket_engine/project/templates/errors.py +25 -0
- rocket_engine/project/testbench/__init__.py +49 -0
- rocket_engine/project/testbench/blocks.py +619 -0
- rocket_engine/project/testbench/templates.py +134 -0
- rocket_engine/stores/README.md +12 -0
- rocket_engine/stores/__init__.py +6 -0
- rocket_engine/stores/ecs.py +1508 -0
- rocket_engine/stores/layers.py +1023 -0
- rocket_engine/stores/settings.py +1188 -0
- rocket_engine/stores/wireplace.py +1324 -0
- rocket_engine/workflows/README.md +18 -0
- rocket_engine/workflows/__init__.py +53 -0
- rocket_engine/workflows/capability_plan.py +102 -0
- rocket_engine/workflows/completion.py +228 -0
- rocket_engine/workflows/connectgraph.py +734 -0
- rocket_engine/workflows/connectgraph_emit.py +336 -0
- rocket_engine/workflows/gates.py +144 -0
- rocket_engine/workflows/photonic_wire.py +76 -0
- rocket_engine/workflows/stages.py +324 -0
- rocket_engine/workflows/viewsync.py +399 -0
- rocket_engine-0.0.2b1.dist-info/METADATA +200 -0
- rocket_engine-0.0.2b1.dist-info/RECORD +241 -0
- rocket_engine-0.0.2b1.dist-info/WHEEL +4 -0
- rocket_engine-0.0.2b1.dist-info/entry_points.txt +2 -0
- rocket_engine-0.0.2b1.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"""Ifdef-aware property sites plus the vacuity guard for run_formal.
|
|
2
|
+
|
|
3
|
+
Helper behind FORMAL-EDGE: :func:`property_sites` counts only the
|
|
4
|
+
assume/assert/cover sites that survive Verilog preprocessing
|
|
5
|
+
(`` `define `` lines never count, `` `ifdef``/`` `ifndef`` branches
|
|
6
|
+
resolve against the active defines), and :func:`guard_vacuous_pass`
|
|
7
|
+
refuses an sby PASS with zero checked properties as a loud
|
|
8
|
+
bounded-vacuous FAIL instead of a bare PASS.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import re
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
DEFAULT_DEFINES = frozenset({"FORMAL"})
|
|
15
|
+
""" pre-defined macros assumed active, matching sby ``read -formal``."""
|
|
16
|
+
|
|
17
|
+
VACUOUS_SCOPE = "bounded-vacuous"
|
|
18
|
+
"""Scope reported when sby PASSes with zero checked properties."""
|
|
19
|
+
|
|
20
|
+
VACUOUS_RULE = "formal_vacuous"
|
|
21
|
+
"""Violation rule for a vacuous (property-free) sby PASS."""
|
|
22
|
+
|
|
23
|
+
_PROP_RE = re.compile(r"\b(assert|assume|cover)\s*\(")
|
|
24
|
+
_DIRECTIVE_RE = re.compile(
|
|
25
|
+
r"^\s*`(ifdef|ifndef|elsif|elif|else|endif|define|undef)\b\s*(\S+)?"
|
|
26
|
+
)
|
|
27
|
+
_DEFINE_ANY_RE = re.compile(r"`\s*define\b")
|
|
28
|
+
_IDENT_RE = re.compile(r"[A-Za-z_][A-Za-z0-9_$]*$")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def property_sites(sources, defines=None):
|
|
32
|
+
"""Active assume/assert/cover sites by file and line.
|
|
33
|
+
|
|
34
|
+
Comment- and preprocess-aware: ``/* */`` block comments (including
|
|
35
|
+
multi-line) plus ``//`` line comments are stripped before matching,
|
|
36
|
+
`` `define `` lines never count (they declare the ``assert`` macro,
|
|
37
|
+
they are not proof obligations), and `` `ifdef``/`` `ifndef``/
|
|
38
|
+
`` `elsif``/`` `else``/`` `endif`` branches resolve against the
|
|
39
|
+
active defines so disabled properties do not inflate the count.
|
|
40
|
+
`` `define``/`` `undef`` lines encountered in an active branch
|
|
41
|
+
update the active set for the lines that follow. Unreadable
|
|
42
|
+
sources are skipped, never fatal.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
sources: Iterable of RTL source paths to scan.
|
|
46
|
+
defines: Pre-defined macro names considered active. None
|
|
47
|
+
means the sby default (FORMAL, matching ``read -formal``).
|
|
48
|
+
|
|
49
|
+
Returns:
|
|
50
|
+
(assumptions, properties) tuple: assumptions carry file plus
|
|
51
|
+
line, properties add the kind (assert or cover).
|
|
52
|
+
"""
|
|
53
|
+
active = (
|
|
54
|
+
set(DEFAULT_DEFINES) if defines is None else set(defines)
|
|
55
|
+
)
|
|
56
|
+
assumptions, properties = [], []
|
|
57
|
+
for source in sources:
|
|
58
|
+
try:
|
|
59
|
+
text = Path(source).read_text(
|
|
60
|
+
encoding="utf-8", errors="replace"
|
|
61
|
+
)
|
|
62
|
+
except OSError:
|
|
63
|
+
continue
|
|
64
|
+
in_block = False
|
|
65
|
+
stack = []
|
|
66
|
+
for lineno, raw in enumerate(text.splitlines(), start=1):
|
|
67
|
+
code, in_block = _strip_block(raw, in_block)
|
|
68
|
+
code = code.split("//", 1)[0]
|
|
69
|
+
directive = _DIRECTIVE_RE.match(code)
|
|
70
|
+
if directive is not None:
|
|
71
|
+
kind, arg = directive.group(1), directive.group(2)
|
|
72
|
+
current = stack[-1]["active"] if stack else True
|
|
73
|
+
if kind in ("ifdef", "ifndef"):
|
|
74
|
+
parent = current
|
|
75
|
+
if arg is not None and _IDENT_RE.match(arg):
|
|
76
|
+
hit = (arg in active) == (kind == "ifdef")
|
|
77
|
+
else:
|
|
78
|
+
hit = True
|
|
79
|
+
now = parent and hit
|
|
80
|
+
stack.append(
|
|
81
|
+
{"parent": parent, "taken": now, "active": now}
|
|
82
|
+
)
|
|
83
|
+
elif kind in ("elsif", "elif"):
|
|
84
|
+
if stack:
|
|
85
|
+
frame = stack[-1]
|
|
86
|
+
parent = frame["parent"]
|
|
87
|
+
if not parent or frame["taken"]:
|
|
88
|
+
frame["active"] = False
|
|
89
|
+
else:
|
|
90
|
+
if arg is not None and _IDENT_RE.match(arg):
|
|
91
|
+
hit = arg in active
|
|
92
|
+
else:
|
|
93
|
+
hit = True
|
|
94
|
+
frame["active"] = hit
|
|
95
|
+
if hit:
|
|
96
|
+
frame["taken"] = True
|
|
97
|
+
elif kind == "else":
|
|
98
|
+
if stack:
|
|
99
|
+
frame = stack[-1]
|
|
100
|
+
parent = frame["parent"]
|
|
101
|
+
now = parent and not frame["taken"]
|
|
102
|
+
frame["active"] = now
|
|
103
|
+
if now:
|
|
104
|
+
frame["taken"] = True
|
|
105
|
+
elif kind == "endif":
|
|
106
|
+
if stack:
|
|
107
|
+
stack.pop()
|
|
108
|
+
elif kind == "define":
|
|
109
|
+
if current and arg is not None:
|
|
110
|
+
name = arg.split("(", 1)[0].strip()
|
|
111
|
+
if _IDENT_RE.match(name):
|
|
112
|
+
active.add(name)
|
|
113
|
+
elif kind == "undef":
|
|
114
|
+
if current and arg is not None:
|
|
115
|
+
active.discard(arg.strip())
|
|
116
|
+
continue
|
|
117
|
+
if stack and not stack[-1]["active"]:
|
|
118
|
+
continue
|
|
119
|
+
if _DEFINE_ANY_RE.search(code):
|
|
120
|
+
continue
|
|
121
|
+
for match in _PROP_RE.finditer(code):
|
|
122
|
+
entry = {"file": str(source), "line": lineno}
|
|
123
|
+
if match.group(1) == "assume":
|
|
124
|
+
assumptions.append(entry)
|
|
125
|
+
else:
|
|
126
|
+
kind = match.group(1)
|
|
127
|
+
properties.append({**entry, "kind": kind})
|
|
128
|
+
return assumptions, properties
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def guard_vacuous_pass(properties, mode=None, depth=None):
|
|
132
|
+
"""Refuse an sby PASS with zero checked properties, loudly.
|
|
133
|
+
|
|
134
|
+
A property-free PASS is a vacuous proof: sby exited 0 but nothing
|
|
135
|
+
was proven. The guard converts it to a bounded-vacuous FAIL
|
|
136
|
+
(error finding, scope ``bounded-vacuous``) so the engine verdict
|
|
137
|
+
is FAIL, never a bare PASS.
|
|
138
|
+
|
|
139
|
+
Args:
|
|
140
|
+
properties: Property entries as returned by property_sites.
|
|
141
|
+
mode: Sby mode string (bmc, prove, or cover) for the message.
|
|
142
|
+
depth: Proof bound in steps for the message.
|
|
143
|
+
|
|
144
|
+
Returns:
|
|
145
|
+
None when at least one property was checked; otherwise a
|
|
146
|
+
mapping with scope plus the formal_vacuous violation.
|
|
147
|
+
|
|
148
|
+
Caution: Converts sby PASS to engine FAIL when properties is
|
|
149
|
+
empty — zero-property designs cannot PASS silently.
|
|
150
|
+
"""
|
|
151
|
+
if properties:
|
|
152
|
+
return None
|
|
153
|
+
where = []
|
|
154
|
+
if mode is not None:
|
|
155
|
+
where.append(f"mode {mode}")
|
|
156
|
+
if depth is not None:
|
|
157
|
+
where.append(f"depth {depth}")
|
|
158
|
+
scope = ", ".join(where) if where else "sby defaults"
|
|
159
|
+
message = (
|
|
160
|
+
f"sby reported PASS with zero checked properties ({scope}): "
|
|
161
|
+
"no active assert/cover site was found — vacuous proof refused "
|
|
162
|
+
"as FAIL (scope bounded-vacuous); add a property to the sources "
|
|
163
|
+
"or check `ifdef guards (FORMAL is assumed defined)."
|
|
164
|
+
)
|
|
165
|
+
return {
|
|
166
|
+
"scope": VACUOUS_SCOPE,
|
|
167
|
+
"violation": {
|
|
168
|
+
"rule": VACUOUS_RULE,
|
|
169
|
+
"severity": "error",
|
|
170
|
+
"message": message,
|
|
171
|
+
},
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def _strip_block(line, in_block):
|
|
176
|
+
"""Remove /* */ spans from one line, threading the block state."""
|
|
177
|
+
out = []
|
|
178
|
+
pos = 0
|
|
179
|
+
while True:
|
|
180
|
+
if in_block:
|
|
181
|
+
end = line.find("*/", pos)
|
|
182
|
+
if end == -1:
|
|
183
|
+
return "".join(out), True
|
|
184
|
+
pos = end + 2
|
|
185
|
+
in_block = False
|
|
186
|
+
continue
|
|
187
|
+
start = line.find("/*", pos)
|
|
188
|
+
if start == -1:
|
|
189
|
+
out.append(line[pos:])
|
|
190
|
+
return "".join(out), False
|
|
191
|
+
end = line.find("*/", start + 2)
|
|
192
|
+
out.append(line[pos:start])
|
|
193
|
+
if end == -1:
|
|
194
|
+
return "".join(out), True
|
|
195
|
+
pos = end + 2
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"""Formal-sby v1 normalizer: v0 parse output to a ResultBundle.
|
|
2
|
+
|
|
3
|
+
Maps the ``run_formal`` parse shape (a measurements mapping with
|
|
4
|
+
mode, depth, scope, sby_status, property counts, failures, and
|
|
5
|
+
counterexamples, plus violations) onto a typed verdict table,
|
|
6
|
+
bound views, numeric measurements, and findings. Pure function of
|
|
7
|
+
the parsed output: no I/O, no tool calls, deterministic ids
|
|
8
|
+
derived from the run id. A FAIL always carries error findings;
|
|
9
|
+
scope text is preserved as table data, never prose.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
TASK = "run_formal"
|
|
13
|
+
|
|
14
|
+
_DIAG_CAP = 240
|
|
15
|
+
|
|
16
|
+
_SEVERITY = {"error": "error", "warning": "warning"}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _cap(text):
|
|
20
|
+
"""Cap one diagnostic string at the bundle prose limit.
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
text: Raw diagnostic text, possibly unbounded tool prose.
|
|
24
|
+
|
|
25
|
+
Returns:
|
|
26
|
+
The text unchanged when short, else truncated with an
|
|
27
|
+
ellipsis marker.
|
|
28
|
+
"""
|
|
29
|
+
text = text if isinstance(text, str) else str(text)
|
|
30
|
+
if len(text) <= _DIAG_CAP:
|
|
31
|
+
return text
|
|
32
|
+
return text[: _DIAG_CAP - 3] + "..."
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _quantity(value, unit):
|
|
36
|
+
"""Build one v1 Quantity, mapping unitless to dimensionless.
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
value: Numeric value.
|
|
40
|
+
unit: Unit string, possibly empty for unitless measures.
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
Quantity mapping with an explicit unit.
|
|
44
|
+
"""
|
|
45
|
+
return {"value": float(value), "unit": unit if unit else "1"}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _provenance(project_id, run_id, tools, provenance):
|
|
49
|
+
"""Build ResultProvenance, defaulting to a placeholder closure.
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
project_id: Project the run belongs to.
|
|
53
|
+
run_id: Run the bundle describes.
|
|
54
|
+
tools: Tool ingredient mappings (id, version, digest?).
|
|
55
|
+
provenance: Full provenance mapping when the caller has
|
|
56
|
+
one; a deterministic placeholder otherwise.
|
|
57
|
+
|
|
58
|
+
Returns:
|
|
59
|
+
Provenance mapping valid against the v1 schema.
|
|
60
|
+
"""
|
|
61
|
+
if provenance is not None:
|
|
62
|
+
return provenance
|
|
63
|
+
ref = {"scope": "project", "id": project_id, "revision": "r1"}
|
|
64
|
+
return {
|
|
65
|
+
"snapshot": dict(ref),
|
|
66
|
+
"input_lock": dict(ref),
|
|
67
|
+
"closure_hash": "0" * 64,
|
|
68
|
+
"tools": [
|
|
69
|
+
{
|
|
70
|
+
"id": item["id"],
|
|
71
|
+
"version": item.get("version", ""),
|
|
72
|
+
"digest": item.get("digest", "0" * 64),
|
|
73
|
+
}
|
|
74
|
+
for item in tools
|
|
75
|
+
],
|
|
76
|
+
"parents": [],
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def normalize(parsed, *, run_id, project_id="project", target=None,
|
|
81
|
+
tools=(), provenance=None):
|
|
82
|
+
"""Normalize one formal parse output to a v1 ResultBundle.
|
|
83
|
+
|
|
84
|
+
Scope, sby status, and per-failure witnesses become a
|
|
85
|
+
verdict table dataset plus a bound table view; property,
|
|
86
|
+
assumption, and depth counts become measurements whose
|
|
87
|
+
status mirrors the proof verdict; violations become
|
|
88
|
+
findings with capped messages.
|
|
89
|
+
|
|
90
|
+
Args:
|
|
91
|
+
parsed: v0 parse mapping with ``measurements`` (a scope
|
|
92
|
+
mapping) and ``violations[]``.
|
|
93
|
+
run_id: Run the bundle describes (anchors all ids).
|
|
94
|
+
project_id: Project the run belongs to.
|
|
95
|
+
target: v1 target mapping; project kind by default.
|
|
96
|
+
tools: Tool ingredient mappings for provenance.
|
|
97
|
+
provenance: Full provenance mapping when the caller has
|
|
98
|
+
one; a deterministic placeholder otherwise.
|
|
99
|
+
|
|
100
|
+
Returns:
|
|
101
|
+
Schema-valid ResultBundle mapping.
|
|
102
|
+
"""
|
|
103
|
+
measures = parsed.get("measurements") or {}
|
|
104
|
+
violations = parsed.get("violations") or []
|
|
105
|
+
scope = measures.get("scope", "unknown")
|
|
106
|
+
sby_status = measures.get("sby_status", "unknown")
|
|
107
|
+
verdict = "PASS" if sby_status == "PASS" and not violations else "FAIL"
|
|
108
|
+
rows = [("scope", str(scope)), ("sby_status", str(sby_status))]
|
|
109
|
+
for failure in measures.get("failures") or []:
|
|
110
|
+
rows.append(
|
|
111
|
+
(f"failure:{failure.get('property', '?')}",
|
|
112
|
+
str(failure.get("kind", "assert")))
|
|
113
|
+
)
|
|
114
|
+
table_id = f"{run_id}:dataset:verdict"
|
|
115
|
+
datasets = [
|
|
116
|
+
{
|
|
117
|
+
"id": table_id,
|
|
118
|
+
"kind": "table",
|
|
119
|
+
"row_count": len(rows),
|
|
120
|
+
"columns": [
|
|
121
|
+
{
|
|
122
|
+
"id": f"{table_id}:aspect",
|
|
123
|
+
"name": "aspect",
|
|
124
|
+
"dtype": "utf8",
|
|
125
|
+
"unit": "1",
|
|
126
|
+
"data": [aspect for aspect, _ in rows],
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"id": f"{table_id}:value",
|
|
130
|
+
"name": "value",
|
|
131
|
+
"dtype": "utf8",
|
|
132
|
+
"unit": "1",
|
|
133
|
+
"data": [value for _, value in rows],
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
"conditions": [],
|
|
137
|
+
}
|
|
138
|
+
]
|
|
139
|
+
views = [
|
|
140
|
+
{
|
|
141
|
+
"id": f"{run_id}:view:verdict",
|
|
142
|
+
"kind": "table",
|
|
143
|
+
"dataset_id": table_id,
|
|
144
|
+
"name": "verdict",
|
|
145
|
+
}
|
|
146
|
+
]
|
|
147
|
+
measurements = []
|
|
148
|
+
for name in ("properties", "assumptions", "depth"):
|
|
149
|
+
if measures.get(name) is not None:
|
|
150
|
+
measurements.append(
|
|
151
|
+
{
|
|
152
|
+
"name": name,
|
|
153
|
+
"value": _quantity(measures[name], "1"),
|
|
154
|
+
"status": verdict,
|
|
155
|
+
}
|
|
156
|
+
)
|
|
157
|
+
findings = [
|
|
158
|
+
{
|
|
159
|
+
"id": f"{run_id}:finding:{index}",
|
|
160
|
+
"severity": _SEVERITY.get(v.get("severity"), "info"),
|
|
161
|
+
"code": v.get("rule", "assert_fail"),
|
|
162
|
+
"message": _cap(v.get("message", "")),
|
|
163
|
+
}
|
|
164
|
+
for index, v in enumerate(violations)
|
|
165
|
+
]
|
|
166
|
+
return {
|
|
167
|
+
"schema": "rocketeda/results/v1",
|
|
168
|
+
"ref": {"scope": "project", "id": run_id, "revision": "r1"},
|
|
169
|
+
"run_id": run_id,
|
|
170
|
+
"task": TASK,
|
|
171
|
+
"target": dict(target)
|
|
172
|
+
if target is not None
|
|
173
|
+
else {"project_id": project_id, "kind": "project"},
|
|
174
|
+
"state": "complete",
|
|
175
|
+
"freshness": "current",
|
|
176
|
+
"convergence": "not_applicable",
|
|
177
|
+
"provenance": _provenance(project_id, run_id, tools, provenance),
|
|
178
|
+
"datasets": datasets,
|
|
179
|
+
"views": views,
|
|
180
|
+
"measurements": measurements,
|
|
181
|
+
"findings": findings,
|
|
182
|
+
"artifacts": [],
|
|
183
|
+
"logs": [],
|
|
184
|
+
"gaps": [],
|
|
185
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"""Gdsfactory layout smoke: import + build + cspdk attach + GDS roundtrip.
|
|
2
|
+
|
|
3
|
+
Smallest honest layout proof: gdsfactory 9.51.0 (uv.lock pin)
|
|
4
|
+
builds a generic straight and — with the vendored cspdk si340
|
|
5
|
+
PDK attached (rev 3323b17b, version 2.1.0) — the cornerstone
|
|
6
|
+
MZI, then a GDS write/read roundtrip preserves cell name,
|
|
7
|
+
polygon count, and bbox. Solver imports stay lazy so bare envs
|
|
8
|
+
fail loud (`missing_dependency`), never fake-green. The cspdk
|
|
9
|
+
tree is git-ignored vendor data: pass `cspdk_path`
|
|
10
|
+
(`scripts/fetch_fixtures.py --only cspdk`) where the package
|
|
11
|
+
is not installed. The full layout Engine adapter is
|
|
12
|
+
GdsfactoryViewsAdapter (generate_views, adapter.py); this smoke is
|
|
13
|
+
its qualification fixture.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import sys
|
|
17
|
+
import tempfile
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
|
|
20
|
+
from ..errors import AdapterError
|
|
21
|
+
|
|
22
|
+
GF_PIN = "9.51.0"
|
|
23
|
+
CSPDK_PIN = "2.1.0"
|
|
24
|
+
CSPDK_PDK = "cspdk.si340"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def gdsfactory_version():
|
|
28
|
+
"""Proven layout version, observable per run (uv.lock pin).
|
|
29
|
+
|
|
30
|
+
Returns:
|
|
31
|
+
Installed gdsfactory version, or "unknown" when the package
|
|
32
|
+
carries no version attribute.
|
|
33
|
+
|
|
34
|
+
Raises:
|
|
35
|
+
AdapterError: missing_dependency when gdsfactory is not
|
|
36
|
+
importable.
|
|
37
|
+
"""
|
|
38
|
+
try:
|
|
39
|
+
import gdsfactory as gf
|
|
40
|
+
except ImportError as exc:
|
|
41
|
+
raise AdapterError(
|
|
42
|
+
"missing_dependency",
|
|
43
|
+
f"gdsfactory is not importable: {exc} "
|
|
44
|
+
"(uv sync).",
|
|
45
|
+
) from exc
|
|
46
|
+
return getattr(gf, "__version__", "unknown")
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _ensure_cspdk(cspdk_path=None):
|
|
50
|
+
"""Import cspdk.si340 from the install or a vendored tree."""
|
|
51
|
+
try:
|
|
52
|
+
from cspdk.si340 import activate_pdk # noqa: F401
|
|
53
|
+
import cspdk
|
|
54
|
+
|
|
55
|
+
return cspdk
|
|
56
|
+
except ImportError:
|
|
57
|
+
pass
|
|
58
|
+
if cspdk_path is not None:
|
|
59
|
+
root = str(Path(cspdk_path).expanduser())
|
|
60
|
+
if root not in sys.path:
|
|
61
|
+
sys.path.insert(0, root)
|
|
62
|
+
try:
|
|
63
|
+
from cspdk.si340 import activate_pdk # noqa: F401
|
|
64
|
+
import cspdk
|
|
65
|
+
|
|
66
|
+
return cspdk
|
|
67
|
+
except ImportError as exc:
|
|
68
|
+
raise AdapterError(
|
|
69
|
+
"missing_dependency",
|
|
70
|
+
f"cspdk.si340 is not importable: {exc} "
|
|
71
|
+
"(scripts/fetch_fixtures.py --only cspdk).",
|
|
72
|
+
) from exc
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def cspdk_version(cspdk_path=None):
|
|
76
|
+
"""Vendored PDK version, observable per run (fetch pin).
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
cspdk_path: Vendored cspdk tree to import from when the
|
|
80
|
+
package is not installed.
|
|
81
|
+
|
|
82
|
+
Returns:
|
|
83
|
+
Installed cspdk version, or "unknown" when the package
|
|
84
|
+
carries no version attribute.
|
|
85
|
+
|
|
86
|
+
Raises:
|
|
87
|
+
AdapterError: missing_dependency when cspdk.si340 is not
|
|
88
|
+
importable from either source.
|
|
89
|
+
"""
|
|
90
|
+
return getattr(_ensure_cspdk(cspdk_path), "__version__", "unknown")
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def _bbox_um(comp):
|
|
94
|
+
box = comp.bbox()
|
|
95
|
+
return [[float(box.left), float(box.bottom)],
|
|
96
|
+
[float(box.right), float(box.top)]]
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def _polygon_total(comp):
|
|
100
|
+
return sum(len(polys) for polys in comp.get_polygons().values())
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def run_layout_smoke(*, cell="mzi", pdk=CSPDK_PDK, cspdk_path=None,
|
|
104
|
+
gds_path=None):
|
|
105
|
+
"""Run the layout smoke live; return the build + roundtrip evidence.
|
|
106
|
+
|
|
107
|
+
Returns `{gdsfactory_version, cspdk_version|None, active_pdk,
|
|
108
|
+
cell, component, ports[], n_polygons, bbox_um, gds_path,
|
|
109
|
+
roundtrip_cell, roundtrip_polygons, roundtrip_bbox_um,
|
|
110
|
+
roundtrip_match}` — plain strings/floats, JSON-friendly.
|
|
111
|
+
`pdk="generic"` builds from the gpdk cell library (no cspdk
|
|
112
|
+
needed); otherwise the cspdk si340 PDK is attached first.
|
|
113
|
+
|
|
114
|
+
Args:
|
|
115
|
+
cell: Cell name to build from the active PDK.
|
|
116
|
+
pdk: PDK to attach ("generic" skips cspdk).
|
|
117
|
+
cspdk_path: Vendored cspdk tree when the package is not
|
|
118
|
+
installed.
|
|
119
|
+
gds_path: GDS output path; a temp file when omitted.
|
|
120
|
+
|
|
121
|
+
Returns:
|
|
122
|
+
Build + roundtrip evidence mapping (versions, ports,
|
|
123
|
+
polygon counts, bboxes, roundtrip match).
|
|
124
|
+
|
|
125
|
+
Raises:
|
|
126
|
+
AdapterError: invalid_command on bad parameters or an
|
|
127
|
+
unknown cell, missing_dependency where
|
|
128
|
+
gdsfactory/cspdk are uninstalled.
|
|
129
|
+
"""
|
|
130
|
+
if not isinstance(cell, str) or not cell:
|
|
131
|
+
raise AdapterError(
|
|
132
|
+
"invalid_command",
|
|
133
|
+
f"Layout smoke needs a cell name, got {cell!r}.",
|
|
134
|
+
)
|
|
135
|
+
try:
|
|
136
|
+
import gdsfactory as gf
|
|
137
|
+
except ImportError as exc:
|
|
138
|
+
raise AdapterError(
|
|
139
|
+
"missing_dependency",
|
|
140
|
+
f"gdsfactory is not importable: {exc} "
|
|
141
|
+
"(uv sync).",
|
|
142
|
+
) from exc
|
|
143
|
+
if pdk == "generic":
|
|
144
|
+
gf.gpdk.PDK.activate()
|
|
145
|
+
cspdk_ver = None
|
|
146
|
+
else:
|
|
147
|
+
cspdk = _ensure_cspdk(cspdk_path)
|
|
148
|
+
cspdk_ver = getattr(cspdk, "__version__", "unknown")
|
|
149
|
+
from cspdk.si340 import activate_pdk
|
|
150
|
+
|
|
151
|
+
activate_pdk()
|
|
152
|
+
from gdsfactory.pdk import get_active_pdk
|
|
153
|
+
|
|
154
|
+
active = get_active_pdk()
|
|
155
|
+
try:
|
|
156
|
+
factory = active.cells[cell]
|
|
157
|
+
except KeyError as exc:
|
|
158
|
+
raise AdapterError(
|
|
159
|
+
"invalid_command",
|
|
160
|
+
f"Unknown cell {cell!r} in PDK {active.name!r}.",
|
|
161
|
+
) from exc
|
|
162
|
+
comp = factory()
|
|
163
|
+
ports = sorted(port.name for port in comp.ports)
|
|
164
|
+
n_polygons = _polygon_total(comp)
|
|
165
|
+
bbox = _bbox_um(comp)
|
|
166
|
+
if gds_path is None:
|
|
167
|
+
with tempfile.NamedTemporaryFile(
|
|
168
|
+
suffix=".gds", prefix=f"gf_smoke_{cell}_", delete=False
|
|
169
|
+
) as handle:
|
|
170
|
+
gds_path = handle.name
|
|
171
|
+
comp.write_gds(gds_path)
|
|
172
|
+
mirror = gf.import_gds(gds_path)
|
|
173
|
+
rt_polygons = _polygon_total(mirror)
|
|
174
|
+
rt_bbox = _bbox_um(mirror)
|
|
175
|
+
match = (
|
|
176
|
+
mirror.name == comp.name
|
|
177
|
+
and rt_polygons == n_polygons
|
|
178
|
+
and rt_bbox == bbox
|
|
179
|
+
)
|
|
180
|
+
return {
|
|
181
|
+
"gdsfactory_version": getattr(gf, "__version__", "unknown"),
|
|
182
|
+
"cspdk_version": cspdk_ver,
|
|
183
|
+
"active_pdk": active.name,
|
|
184
|
+
"cell": cell,
|
|
185
|
+
"component": comp.name,
|
|
186
|
+
"ports": ports,
|
|
187
|
+
"n_polygons": n_polygons,
|
|
188
|
+
"bbox_um": bbox,
|
|
189
|
+
"gds_path": str(gds_path),
|
|
190
|
+
"roundtrip_cell": mirror.name,
|
|
191
|
+
"roundtrip_polygons": rt_polygons,
|
|
192
|
+
"roundtrip_bbox_um": rt_bbox,
|
|
193
|
+
"roundtrip_match": match,
|
|
194
|
+
}
|