orfeas_petri_flow 0.9.1 → 1.0.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 80d3253e6176f17c7151ac2dbee13262191b47227086cde06368a16e3f383d54
4
- data.tar.gz: 561097bcdfec839f57ccf12dcad6f29faa5c9a3e33ea1c528ed2813a15565696
3
+ metadata.gz: d9cbc8ff96618fd5882f9c4a77556594ffd6eda4db5499dd8bb0577f5d7aa091
4
+ data.tar.gz: c48d63fc243271cf9d7e4062dd47c9727db3464f844881a69200ddad38efba5c
5
5
  SHA512:
6
- metadata.gz: fadca4c6e0d39a2a84cce8a60b17202f471bc5a1d8a84f22c35c7b25907d18d226b9addc8d1fa42068bbe59a26a4ba3798897d79f8f4cdf05b2cb1e1a7232d05
7
- data.tar.gz: 1c8846f9229587f88ec5ef043a1319ecc959ba153d1579fe10ec69d6d263c56b646cc6ba7cf1b1ee667e9b5b4dad335d54dd0ecc2d0e6ba7eb84b9a93b6ba513
6
+ metadata.gz: 9781d473fff37db31c240ba08490e14d4e9c9f136d3e7da91ea2197b8a722d6971ec20a7886e7ee1e4d143e4788766054b7b627e347618059c35de1f950a53bc
7
+ data.tar.gz: b57d00e5dce2e1df0b036bc31cbebe08be2a193272b2cb6220430654d51411ca8abd468f7b6e43f6b9462debf60608527618688cc8280e0e2cf919e327b3d8dc
data/CHANGELOG.md CHANGED
@@ -4,6 +4,28 @@ All notable changes to the PetriFlow gem will be documented in this file.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [1.0.0] - 2026-11-22
8
+
9
+ Released with Lyra 1.0.0 and PAM DSL 1.0.0.
10
+
11
+ ### Changed
12
+ - **The gems' MIT-LICENSE copyright line no longer names the University of the Aegean**, which is
13
+ the author's affiliation, not a copyright holder.
14
+ - **`rake petri_flow:verify` exits 1 when a workflow fails verification**: a terminal place it
15
+ cannot reach, an unbounded net, or a run that can stop short of a terminal place. The reports
16
+ are written first, as before. `PETRI_FLOW_EXPECTED_FAILURES` (class names, comma-separated)
17
+ exempts a workflow kept flawed on purpose, as a demonstration. It used to exit 0 whatever it
18
+ found.
19
+
20
+ ## [0.9.3] - 2026-11-04
21
+
22
+ ### Security
23
+ - **Graphviz is run without a shell.** `VerificationRunner#generate_graphviz_images` and
24
+ `Visualization::Graphviz#render` built a shell command from the report directory, the
25
+ workflow's name, the output path and the layout. They now pass Graphviz its arguments one by
26
+ one, and `render` accepts only Graphviz's layout engines (`Graphviz::LAYOUTS`) and plain format
27
+ names, raising `ArgumentError` otherwise. The version moves to 0.9.3, with Lyra and PAM DSL.
28
+
7
29
  ## [0.9.1] - 2026-11-02
8
30
 
9
31
  ### Changed
data/MIT-LICENSE CHANGED
@@ -1,7 +1,6 @@
1
1
  MIT License
2
2
 
3
3
  Copyright (c) 2025 Michail Pantelelis (mpantel@aegean.gr)
4
- University of the Aegean - ORFEAS Framework
5
4
 
6
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
7
6
  of this software and associated documentation files (the "Software"), to deal
@@ -27,7 +27,25 @@ namespace :petri_flow do
27
27
  end
28
28
 
29
29
  runner = PetriFlow::VerificationRunner.new
30
- runner.run_all
30
+ results = runner.run_all
31
+
32
+ # A workflow fails verification when a terminal place is unreachable, the
33
+ # net is unbounded, or it can stop short of a terminal place. The reports
34
+ # are written either way; then the task exits 1 if any failed, unless
35
+ # PETRI_FLOW_EXPECTED_FAILURES names it (a workflow kept flawed on purpose,
36
+ # as a demonstration).
37
+ failed = results.filter_map do |_id, r|
38
+ unreachable = r[:terminal_reachability].select { |_place, reachable| !reachable }.keys
39
+ unbounded = r.dig(:verification, :boundedness, :is_bounded) == false
40
+ improper = r.dig(:verification, :liveness, :terminates_properly) == false
41
+ next if unreachable.empty? && !unbounded && !improper
42
+
43
+ [r[:class_name], { unreachable: unreachable, unbounded: unbounded, terminates_improperly: improper }]
44
+ end.to_h
45
+ expected = ENV.fetch("PETRI_FLOW_EXPECTED_FAILURES", "").split(",").map(&:strip)
46
+ unexpected = failed.except(*expected)
47
+ failed.each { |name, why| puts "#{expected.include?(name) ? 'expected failure' : 'FAILED'}: #{name} #{why}" }
48
+ abort "petri_flow:verify: #{unexpected.size} workflow(s) failed verification: #{unexpected.keys.join(', ')}" if unexpected.any?
31
49
  end
32
50
 
33
51
  namespace :verify do
@@ -169,13 +169,14 @@ module PetriFlow
169
169
  end
170
170
 
171
171
  def graphviz_available?
172
- system("which dot > /dev/null 2>&1")
172
+ system("which", "dot", out: File::NULL, err: File::NULL)
173
173
  end
174
174
 
175
175
  def generate_graphviz_images(dot_file, workflow_id)
176
176
  %w[png pdf svg].each do |format|
177
177
  output_file = File.join(@reports_dir, "#{workflow_id}_petri.#{format}")
178
- system("dot -T#{format} #{dot_file} -o #{output_file} 2>/dev/null")
178
+ # Arguments, not a shell string: the paths never reach a shell.
179
+ system("dot", "-T#{format}", dot_file, "-o", output_file, err: File::NULL)
179
180
  end
180
181
  end
181
182
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PetriFlow
4
- VERSION = "0.9.1"
4
+ VERSION = "1.0.0"
5
5
  end
@@ -21,6 +21,9 @@ module PetriFlow
21
21
  rankdir: "TB" # TB (top-bottom), LR (left-right)
22
22
  }.freeze
23
23
 
24
+ # Graphviz layout engines render accepts, each the name of its executable.
25
+ LAYOUTS = %w[dot neato fdp sfdp circo twopi osage patchwork].freeze
26
+
24
27
  def initialize(net, options = {})
25
28
  @net = net
26
29
  @options = DEFAULT_OPTIONS.merge(options)
@@ -69,10 +72,13 @@ module PetriFlow
69
72
  def render(output_file, format: "png")
70
73
  require 'open3'
71
74
 
72
- dot_content = to_dot
73
- cmd = "#{@options[:layout]} -T#{format} -o #{output_file}"
75
+ layout = @options[:layout].to_s
76
+ raise ArgumentError, "unknown Graphviz layout #{layout.inspect} (one of #{LAYOUTS.join(', ')})" unless LAYOUTS.include?(layout)
77
+ raise ArgumentError, "invalid Graphviz format #{format.inspect}" unless format.to_s.match?(/\A[a-z0-9:]+\z/)
74
78
 
75
- stdout, stderr, status = Open3.capture3(cmd, stdin_data: dot_content)
79
+ dot_content = to_dot
80
+ # Arguments, not a shell string: no path or option reaches a shell.
81
+ stdout, stderr, status = Open3.capture3(layout, "-T#{format}", "-o", output_file.to_s, stdin_data: dot_content)
76
82
 
77
83
  unless status.success?
78
84
  raise "Graphviz rendering failed: #{stderr}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orfeas_petri_flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michail Pantelelis