scjson 0.3.4__tar.gz → 0.3.6__tar.gz

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.
Files changed (76) hide show
  1. {scjson-0.3.4 → scjson-0.3.6}/MANIFEST.in +1 -1
  2. {scjson-0.3.4/scjson.egg-info → scjson-0.3.6}/PKG-INFO +2 -2
  3. {scjson-0.3.4 → scjson-0.3.6}/exec_compare.py +66 -2
  4. {scjson-0.3.4 → scjson-0.3.6}/pyproject.toml +6 -3
  5. {scjson-0.3.4 → scjson-0.3.6}/scjson/cli.py +32 -1
  6. scjson-0.3.6/scjson/dataclasses/__init__.py +121 -0
  7. scjson-0.3.6/scjson/dataclasses/generated.py +1754 -0
  8. scjson-0.3.6/scjson/dataclasses_strict/__init__.py +121 -0
  9. scjson-0.3.6/scjson/dataclasses_strict/generated.py +1761 -0
  10. scjson-0.3.6/scjson/pydantic/__init__.py +121 -0
  11. scjson-0.3.6/scjson/pydantic/generated.py +1185 -0
  12. scjson-0.3.6/scjson/pydantic_strict/__init__.py +121 -0
  13. scjson-0.3.6/scjson/pydantic_strict/generated.py +1188 -0
  14. scjson-0.3.6/scjson/templates/base.rb.jinja2 +4 -0
  15. scjson-0.3.6/scjson/templates/base.rs.jinja2 +2 -0
  16. scjson-0.3.6/scjson/templates/base.swift.jinja2 +4 -0
  17. scjson-0.3.6/scjson/templates/base.ts.jinja2 +21 -0
  18. scjson-0.3.6/scjson/templates/scjson_props.rb.jinja2 +152 -0
  19. scjson-0.3.6/scjson/templates/scjson_props.rs.jinja2 +96 -0
  20. scjson-0.3.6/scjson/templates/scjson_props.swift.jinja2 +184 -0
  21. scjson-0.3.6/scjson/templates/scjson_props.ts.jinja2 +150 -0
  22. {scjson-0.3.4 → scjson-0.3.6/scjson.egg-info}/PKG-INFO +2 -2
  23. {scjson-0.3.4 → scjson-0.3.6}/scjson.egg-info/SOURCES.txt +20 -1
  24. {scjson-0.3.4 → scjson-0.3.6}/scjson.egg-info/top_level.txt +1 -0
  25. {scjson-0.3.4 → scjson-0.3.6}/tests/__pycache__/test_cli.cpython-311-pytest-8.4.1.pyc +0 -0
  26. {scjson-0.3.4 → scjson-0.3.6}/tests/__pycache__/test_engine.cpython-311-pytest-8.4.1.pyc +0 -0
  27. {scjson-0.3.4 → scjson-0.3.6}/tests/__pycache__/test_engine_cli.cpython-311-pytest-8.4.1.pyc +0 -0
  28. {scjson-0.3.4 → scjson-0.3.6}/tests/__pycache__/test_exec_compare_advanced.cpython-311-pytest-8.4.1.pyc +0 -0
  29. {scjson-0.3.4 → scjson-0.3.6}/tests/__pycache__/test_exec_compare_integration.cpython-311-pytest-8.4.1.pyc +0 -0
  30. {scjson-0.3.4 → scjson-0.3.6}/tests/__pycache__/test_exec_sweep_corpus.cpython-311-pytest-8.4.1.pyc +0 -0
  31. {scjson-0.3.4 → scjson-0.3.6}/tests/__pycache__/test_exec_sweep_integration.cpython-311-pytest-8.4.1.pyc +0 -0
  32. {scjson-0.3.4 → scjson-0.3.6}/tests/__pycache__/test_json_stream.cpython-311-pytest-8.4.1.pyc +0 -0
  33. {scjson-0.3.4 → scjson-0.3.6}/tests/__pycache__/test_safe_eval.cpython-311-pytest-8.4.1.pyc +0 -0
  34. {scjson-0.3.4 → scjson-0.3.6}/tests/__pycache__/test_vector_analyzer.cpython-311-pytest-8.4.1.pyc +0 -0
  35. {scjson-0.3.4 → scjson-0.3.6}/tests/__pycache__/test_vector_coverage.cpython-311-pytest-8.4.1.pyc +0 -0
  36. {scjson-0.3.4 → scjson-0.3.6}/tests/__pycache__/test_vector_gen.cpython-311-pytest-8.4.1.pyc +0 -0
  37. {scjson-0.3.4 → scjson-0.3.6}/tests/__pycache__/test_vector_invoke.cpython-311-pytest-8.4.1.pyc +0 -0
  38. {scjson-0.3.4 → scjson-0.3.6}/tests/__pycache__/test_vector_search.cpython-311-pytest-8.4.1.pyc +0 -0
  39. scjson-0.3.6/vector_lib/analyzer.py +463 -0
  40. scjson-0.3.6/vector_lib/coverage.py +71 -0
  41. scjson-0.3.6/vector_lib/search.py +123 -0
  42. {scjson-0.3.4 → scjson-0.3.6}/LEGAL.md +0 -0
  43. {scjson-0.3.4 → scjson-0.3.6}/LICENSE +0 -0
  44. {scjson-0.3.4 → scjson-0.3.6}/README.md +0 -0
  45. {scjson-0.3.4 → scjson-0.3.6}/exec_sweep.py +0 -0
  46. {scjson-0.3.4 → scjson-0.3.6}/scjson/CaseStyle.py +0 -0
  47. {scjson-0.3.4 → scjson-0.3.6}/scjson/SCXMLDocumentHandler.py +0 -0
  48. {scjson-0.3.4 → scjson-0.3.6}/scjson/__init__.py +0 -0
  49. {scjson-0.3.4 → scjson-0.3.6}/scjson/__main__.py +0 -0
  50. {scjson-0.3.4 → scjson-0.3.6}/scjson/activation.py +0 -0
  51. {scjson-0.3.4 → scjson-0.3.6}/scjson/context.py +0 -0
  52. {scjson-0.3.4 → scjson-0.3.6}/scjson/engine.py +0 -0
  53. {scjson-0.3.4 → scjson-0.3.6}/scjson/events.py +0 -0
  54. {scjson-0.3.4 → scjson-0.3.6}/scjson/invoke.py +0 -0
  55. {scjson-0.3.4 → scjson-0.3.6}/scjson/jinja_gen.py +0 -0
  56. {scjson-0.3.4 → scjson-0.3.6}/scjson/json_stream.py +0 -0
  57. {scjson-0.3.4 → scjson-0.3.6}/scjson/safe_eval.py +0 -0
  58. {scjson-0.3.4 → scjson-0.3.6}/scjson.egg-info/dependency_links.txt +0 -0
  59. {scjson-0.3.4 → scjson-0.3.6}/scjson.egg-info/entry_points.txt +0 -0
  60. {scjson-0.3.4 → scjson-0.3.6}/scjson.egg-info/requires.txt +0 -0
  61. {scjson-0.3.4 → scjson-0.3.6}/setup.cfg +0 -0
  62. {scjson-0.3.4 → scjson-0.3.6}/tests/test_cli.py +0 -0
  63. {scjson-0.3.4 → scjson-0.3.6}/tests/test_engine.py +0 -0
  64. {scjson-0.3.4 → scjson-0.3.6}/tests/test_engine_cli.py +0 -0
  65. {scjson-0.3.4 → scjson-0.3.6}/tests/test_exec_compare_advanced.py +0 -0
  66. {scjson-0.3.4 → scjson-0.3.6}/tests/test_exec_compare_integration.py +0 -0
  67. {scjson-0.3.4 → scjson-0.3.6}/tests/test_exec_sweep_corpus.py +0 -0
  68. {scjson-0.3.4 → scjson-0.3.6}/tests/test_exec_sweep_integration.py +0 -0
  69. {scjson-0.3.4 → scjson-0.3.6}/tests/test_json_stream.py +0 -0
  70. {scjson-0.3.4 → scjson-0.3.6}/tests/test_safe_eval.py +0 -0
  71. {scjson-0.3.4 → scjson-0.3.6}/tests/test_vector_analyzer.py +0 -0
  72. {scjson-0.3.4 → scjson-0.3.6}/tests/test_vector_coverage.py +0 -0
  73. {scjson-0.3.4 → scjson-0.3.6}/tests/test_vector_gen.py +0 -0
  74. {scjson-0.3.4 → scjson-0.3.6}/tests/test_vector_invoke.py +0 -0
  75. {scjson-0.3.4 → scjson-0.3.6}/tests/test_vector_search.py +0 -0
  76. {scjson-0.3.4 → scjson-0.3.6}/vector_gen.py +0 -0
@@ -2,4 +2,4 @@ include README.md
2
2
  include LEGAL.md
3
3
  include LICENSE
4
4
  recursive-include tests *
5
- recursive-include templates *
5
+ recursive-include scjson/templates *
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scjson
3
- Version: 0.3.4
4
- Summary: A JSON-based serialization of SCXML (State Chart XML) for modern tooling, interoperability, and education.
3
+ Version: 0.3.6
4
+ Summary: A JSON-based serialization of SCXML (State Chart XML) for modern tooling, interoperability, and education, with execution engine and trace tools for SCXML/SCML.
5
5
  Author-email: Ira Abbott <ira@mycloud.blue>
6
6
  License-Expression: BSD-1-Clause
7
7
  Requires-Python: >=3.8
@@ -445,11 +445,22 @@ def main() -> None:
445
445
  type=Path,
446
446
  help="Directory for trace artifacts (defaults to temporary directory)",
447
447
  )
448
+ # Step-0 state normalization: allow explicit keep/strip and auto mode
448
449
  parser.add_argument(
449
450
  "--keep-step0-states",
451
+ dest="keep_step0_states",
450
452
  action="store_true",
451
- default=True,
452
- help="Do not strip step-0 entered/exited state lists during normalization",
453
+ default=None,
454
+ help=(
455
+ "Keep step-0 entered/exited state lists. By default, the tool auto-"
456
+ "detects reference engine and strips when using SCION to reduce noise."
457
+ ),
458
+ )
459
+ parser.add_argument(
460
+ "--strip-step0-states",
461
+ dest="keep_step0_states",
462
+ action="store_false",
463
+ help="Strip step-0 entered/exited state lists during normalization",
453
464
  )
454
465
  parser.add_argument(
455
466
  "--leaf-only",
@@ -510,6 +521,15 @@ def main() -> None:
510
521
  default="tolerant",
511
522
  help="Ordering policy for child→parent emissions (finalize, etc.)",
512
523
  )
524
+ parser.add_argument(
525
+ "--norm",
526
+ type=str,
527
+ choices=["scion"],
528
+ help=(
529
+ "Apply a normalization profile. 'scion' sets leaf-only, omit-delta, "
530
+ "omit-transitions, strip-step0-states, and ordering=scion."
531
+ ),
532
+ )
513
533
  args = parser.parse_args()
514
534
 
515
535
  chart = args.chart.resolve()
@@ -572,8 +592,24 @@ def main() -> None:
572
592
  raise SystemExit(f"Event stream not found: {events}")
573
593
 
574
594
  # treat_as_xml already computed above
595
+ # Apply normalization profile defaults before resolving commands
596
+ if args.norm == "scion":
597
+ args.leaf_only = True
598
+ args.omit_delta = True
599
+ args.omit_transitions = True
600
+ args.keep_step0_states = False
601
+ args.ordering = "scion"
602
+
575
603
  ref_cmd = _resolve_reference_cmd(args)
576
604
 
605
+ # If not explicitly specified, auto-set step-0 state normalization when using SCION as reference
606
+ if args.keep_step0_states is None:
607
+ try:
608
+ ref_joined = " ".join(ref_cmd).lower()
609
+ args.keep_step0_states = not ("scion" in ref_joined or "scion-runner" in ref_joined)
610
+ except Exception:
611
+ args.keep_step0_states = True
612
+
577
613
  temp_dir: TemporaryDirectory[str] | None = None
578
614
  workdir = args.workdir
579
615
  if workdir is None:
@@ -604,10 +640,19 @@ def main() -> None:
604
640
  py_flags.extend(["--ordering", args.ordering])
605
641
 
606
642
  try:
643
+ # Honor optional WORKDIR_OVERRIDE from environment
644
+ if os.environ.get("WORKDIR_OVERRIDE"):
645
+ workdir = Path(os.environ["WORKDIR_OVERRIDE"]) # type: ignore
646
+ workdir.mkdir(parents=True, exist_ok=True)
647
+ py_trace = workdir / "python.trace.jsonl"
607
648
  _run(_build_trace_cmd(py_cmd, chart, events, py_trace, treat_as_xml, py_flags))
608
649
  except SystemExit:
609
650
  # Fallback to inline generation when package CLI is unavailable
610
651
  _write_python_trace_inline(chart, events, py_trace, treat_as_xml, ordering=args.ordering)
652
+ if os.environ.get("WORKDIR_OVERRIDE"):
653
+ workdir = Path(os.environ["WORKDIR_OVERRIDE"]) # type: ignore
654
+ workdir.mkdir(parents=True, exist_ok=True)
655
+ ref_trace = workdir / "reference.trace.jsonl"
611
656
  _run(_build_trace_cmd(ref_cmd, chart, events, ref_trace, treat_as_xml))
612
657
 
613
658
  py_steps = _load_trace(py_trace)
@@ -664,8 +709,27 @@ def main() -> None:
664
709
 
665
710
  if secondary_cmd:
666
711
  secondary_trace = workdir / "secondary.trace.jsonl"
712
+ # Honor optional WORKDIR_OVERRIDE from environment (for CI harness retention)
713
+ if os.environ.get("WORKDIR_OVERRIDE"):
714
+ workdir = Path(os.environ["WORKDIR_OVERRIDE"]) # type: ignore
715
+ workdir.mkdir(parents=True, exist_ok=True)
716
+ secondary_trace = workdir / "secondary.trace.jsonl"
667
717
  _run(_build_trace_cmd(secondary_cmd, chart, events, secondary_trace, treat_as_xml))
668
718
  secondary_steps = _load_trace(secondary_trace)
719
+ # Apply normalization to secondary to align with ref_steps
720
+ if args.leaf_only:
721
+ leaf_ids = _leaf_ids_from_chart(chart, treat_as_xml)
722
+ secondary_steps = _normalize_steps_leaf_only(secondary_steps, leaf_ids)
723
+ secondary_steps = _strip_step0_noise(secondary_steps)
724
+ if not args.keep_step0_states:
725
+ secondary_steps = _strip_step0_states(secondary_steps)
726
+ secondary_steps = _omit_fields(
727
+ secondary_steps,
728
+ omit_actions=args.omit_actions,
729
+ omit_delta=args.omit_delta,
730
+ omit_transitions=args.omit_transitions,
731
+ )
732
+ secondary_steps = _normalize_transition_conditions(secondary_steps)
669
733
  mismatch_sec, notes_sec, stats_sec = _diff_steps(ref_steps, secondary_steps)
670
734
  if mismatch_sec:
671
735
  print("Mismatch detected (reference vs secondary):")
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  name = "scjson"
3
- version = "0.3.4"
4
- description = "A JSON-based serialization of SCXML (State Chart XML) for modern tooling, interoperability, and education."
3
+ version = "0.3.6"
4
+ description = "A JSON-based serialization of SCXML (State Chart XML) for modern tooling, interoperability, and education, with execution engine and trace tools for SCXML/SCML."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.8"
7
7
  license = "BSD-1-Clause"
@@ -28,6 +28,9 @@ requires = ["setuptools>=61.0"]
28
28
  build-backend = "setuptools.build_meta"
29
29
 
30
30
  [tool.setuptools]
31
- packages = ["scjson"]
31
+ include-package-data = true
32
32
  # Install top-level helper modules used by CLI workflows as importable modules
33
33
  py-modules = ["exec_compare", "exec_sweep", "vector_gen"]
34
+
35
+ [tool.setuptools.packages.find]
36
+ include = ["scjson", "scjson.*", "vector_lib"]
@@ -436,6 +436,16 @@ def run(input_path: Path, workdir: Path | None, is_xml: bool) -> None:
436
436
  show_default=True,
437
437
  help="Ordering policy for child→parent emissions (finalize, etc.)",
438
438
  )
439
+ @click.option(
440
+ "--emit-time-steps/--no-emit-time-steps",
441
+ "emit_time_steps",
442
+ is_flag=True,
443
+ default=False,
444
+ help=(
445
+ "When an advance_time control token is seen, emit a synthetic step to flush timers."
446
+ " Disabled by default to keep control tokens from affecting step counts."
447
+ ),
448
+ )
439
449
  def engine_trace(
440
450
  input_path: Path,
441
451
  events_path: Path | None,
@@ -453,6 +463,7 @@ def engine_trace(
453
463
  omit_transitions: bool,
454
464
  advance_time: float,
455
465
  ordering: str,
466
+ emit_time_steps: bool,
456
467
  ) -> None:
457
468
  """Produce a JSON lines trace of engine steps for comparison harnesses.
458
469
 
@@ -555,7 +566,27 @@ def engine_trace(
555
566
  adv = msg.get("advance_time") if isinstance(msg, dict) else None
556
567
  if isinstance(adv, (int, float)) and adv > 0:
557
568
  ctx.advance_time(float(adv))
558
- # Do not emit a trace step for time advancement
569
+ if emit_time_steps:
570
+ trace = ctx.trace_step(Event(name="__time__", data=None))
571
+ if leaf_only:
572
+ leaf_ids = ctx.leaf_state_ids()
573
+ for key in ("configuration", "enteredStates", "exitedStates"):
574
+ vals = trace.get(key)
575
+ if isinstance(vals, list):
576
+ trace[key] = [v for v in vals if v in leaf_ids]
577
+ if omit_actions and "actionLog" in trace:
578
+ trace["actionLog"] = []
579
+ if omit_delta and "datamodelDelta" in trace:
580
+ trace["datamodelDelta"] = {}
581
+ if not omit_delta and isinstance(trace.get("datamodelDelta"), dict):
582
+ dm = trace["datamodelDelta"]
583
+ trace["datamodelDelta"] = {k: dm[k] for k in sorted(dm)}
584
+ if omit_transitions and "firedTransitions" in trace:
585
+ trace["firedTransitions"] = []
586
+ trace["event"] = None
587
+ trace["step"] = step_no
588
+ sink.write(dumps(trace) + "\n")
589
+ step_no += 1
559
590
  continue
560
591
  except Exception:
561
592
  # Fall through to normal event handling
@@ -0,0 +1,121 @@
1
+ from .generated import (
2
+ Assign,
3
+ AssignTypeDatatype,
4
+ BindingDatatype,
5
+ BooleanDatatype,
6
+ Cancel,
7
+ Content,
8
+ Data,
9
+ Datamodel,
10
+ Donedata,
11
+ Else,
12
+ Elseif,
13
+ ExmodeDatatype,
14
+ Final,
15
+ Finalize,
16
+ Foreach,
17
+ History,
18
+ HistoryTypeDatatype,
19
+ If,
20
+ Initial,
21
+ Invoke,
22
+ Log,
23
+ Onentry,
24
+ Onexit,
25
+ Parallel,
26
+ Param,
27
+ Raise,
28
+ Script,
29
+ Scxml,
30
+ ScxmlAssignType,
31
+ ScxmlCancelType,
32
+ ScxmlContentType,
33
+ ScxmlDatamodelType,
34
+ ScxmlDataType,
35
+ ScxmlDonedataType,
36
+ ScxmlElseifType,
37
+ ScxmlElseType,
38
+ ScxmlFinalizeType,
39
+ ScxmlFinalType,
40
+ ScxmlForeachType,
41
+ ScxmlHistoryType,
42
+ ScxmlIfType,
43
+ ScxmlInitialType,
44
+ ScxmlInvokeType,
45
+ ScxmlLogType,
46
+ ScxmlOnentryType,
47
+ ScxmlOnexitType,
48
+ ScxmlParallelType,
49
+ ScxmlParamType,
50
+ ScxmlRaiseType,
51
+ ScxmlScriptType,
52
+ ScxmlScxmlType,
53
+ ScxmlSendType,
54
+ ScxmlStateType,
55
+ ScxmlTransitionType,
56
+ Send,
57
+ State,
58
+ Transition,
59
+ TransitionTypeDatatype,
60
+ )
61
+
62
+ __all__ = [
63
+ "AssignTypeDatatype",
64
+ "BindingDatatype",
65
+ "BooleanDatatype",
66
+ "ExmodeDatatype",
67
+ "HistoryTypeDatatype",
68
+ "TransitionTypeDatatype",
69
+ "Assign",
70
+ "Cancel",
71
+ "Content",
72
+ "Data",
73
+ "Datamodel",
74
+ "Donedata",
75
+ "Else",
76
+ "Elseif",
77
+ "Final",
78
+ "Finalize",
79
+ "Foreach",
80
+ "History",
81
+ "If",
82
+ "Initial",
83
+ "Invoke",
84
+ "Log",
85
+ "Onentry",
86
+ "Onexit",
87
+ "Parallel",
88
+ "Param",
89
+ "Raise",
90
+ "Script",
91
+ "Scxml",
92
+ "ScxmlAssignType",
93
+ "ScxmlCancelType",
94
+ "ScxmlContentType",
95
+ "ScxmlDataType",
96
+ "ScxmlDatamodelType",
97
+ "ScxmlDonedataType",
98
+ "ScxmlElseType",
99
+ "ScxmlElseifType",
100
+ "ScxmlFinalType",
101
+ "ScxmlFinalizeType",
102
+ "ScxmlForeachType",
103
+ "ScxmlHistoryType",
104
+ "ScxmlIfType",
105
+ "ScxmlInitialType",
106
+ "ScxmlInvokeType",
107
+ "ScxmlLogType",
108
+ "ScxmlOnentryType",
109
+ "ScxmlOnexitType",
110
+ "ScxmlParallelType",
111
+ "ScxmlParamType",
112
+ "ScxmlRaiseType",
113
+ "ScxmlScriptType",
114
+ "ScxmlScxmlType",
115
+ "ScxmlSendType",
116
+ "ScxmlStateType",
117
+ "ScxmlTransitionType",
118
+ "Send",
119
+ "State",
120
+ "Transition",
121
+ ]