archsight 0.5.2 → 0.5.4
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 +4 -4
- data/README.md +2 -0
- data/docs/archimate.md +1 -1
- data/docs/configuration.md +1 -1
- data/docs/diagram.md +12 -2
- data/docs/import.md +27 -2
- data/docs/modeling.md +17 -6
- data/docs/pages.md +1 -1
- data/docs/search.md +19 -0
- data/lib/archsight/annotations/capacity_annotations.rb +15 -0
- data/lib/archsight/database.rb +1 -1
- data/lib/archsight/diagram/graph/attributes.rb +11 -3
- data/lib/archsight/diagram/graph/builder.rb +1 -0
- data/lib/archsight/diagram/graph/node.rb +26 -2
- data/lib/archsight/diagram/layout/expander.rb +39 -0
- data/lib/archsight/diagram/layout.rb +11 -0
- data/lib/archsight/diagram/legend/inventory.rb +6 -2
- data/lib/archsight/diagram/parser.rb +1 -1
- data/lib/archsight/diagram/renderer/node_renderer.rb +6 -1
- data/lib/archsight/diagram/renderer/stylesheet.rb +2 -0
- data/lib/archsight/diagram/style/representers.rb +14 -0
- data/lib/archsight/diagram/support/text_metrics.rb +38 -0
- data/lib/archsight/git_source.rb +5 -3
- data/lib/archsight/helpers.rb +3 -1
- data/lib/archsight/import/handlers/gitea.rb +195 -0
- data/lib/archsight/import/handlers/github.rb +1 -0
- data/lib/archsight/import/handlers/gitlab.rb +1 -0
- data/lib/archsight/import/handlers/repository.rb +32 -4
- data/lib/archsight/linter.rb +13 -2
- data/lib/archsight/mcp/analyze_resource_tool.rb +145 -43
- data/lib/archsight/mcp/base.rb +112 -5
- data/lib/archsight/mcp/execute_analysis_tool.rb +11 -1
- data/lib/archsight/mcp/query_hints.rb +119 -0
- data/lib/archsight/mcp/query_tool.rb +90 -5
- data/lib/archsight/mcp/relations_tool.rb +89 -0
- data/lib/archsight/mcp/resource_doc_tool.rb +39 -20
- data/lib/archsight/mcp/summary_tool.rb +106 -0
- data/lib/archsight/mcp.rb +2 -0
- data/lib/archsight/query/ast.rb +28 -0
- data/lib/archsight/query/evaluator.rb +2 -0
- data/lib/archsight/query/lexer.rb +2 -2
- data/lib/archsight/query/parser.rb +45 -0
- data/lib/archsight/query/text_search.rb +38 -0
- data/lib/archsight/query.rb +1 -0
- data/lib/archsight/reading_time.rb +66 -0
- data/lib/archsight/resources/base.rb +12 -0
- data/lib/archsight/resources/business_contract.rb +8 -1
- data/lib/archsight/resources/config.rb +28 -0
- data/lib/archsight/resources/implementation_work_package.rb +2 -0
- data/lib/archsight/resources/motivation_requirement.rb +10 -0
- data/lib/archsight/resources/technology_device.rb +14 -0
- data/lib/archsight/resources/technology_equipment.rb +3 -1
- data/lib/archsight/resources/technology_node.rb +8 -1
- data/lib/archsight/summary/builder.rb +204 -0
- data/lib/archsight/summary/lens.rb +224 -0
- data/lib/archsight/summary.rb +11 -0
- data/lib/archsight/version.rb +1 -1
- data/lib/archsight/web/api/openapi/spec.yaml +20 -1
- data/lib/archsight/web/api/page_helpers.rb +5 -1
- data/lib/archsight/web/application.rb +2 -0
- data/lib/archsight/web/public/vue/{DocPage-B2AVspsD.js → DocPage-BHffBQ3u.js} +1 -1
- data/lib/archsight/web/public/vue/{EditorPage-BYSZG_O0.js → EditorPage-BHZtvtnN.js} +1 -1
- data/lib/archsight/web/public/vue/{ErrorPage-eL_Woec4.js → ErrorPage-BQARAwF8.js} +1 -1
- data/lib/archsight/web/public/vue/{GraphView-YEiPBxPd.js → GraphView-D84CH00D.js} +1 -1
- data/lib/archsight/web/public/vue/{HomePage-BeLTwv2y.js → HomePage-BJpTPWFz.js} +2 -2
- data/lib/archsight/web/public/vue/{InstanceRouter-DgvdUouW.js → InstanceRouter-C1Da3nWo.js} +1 -1
- data/lib/archsight/web/public/vue/{KindList-BkYvYpnh.js → KindList-DNRUVuEJ.js} +1 -1
- data/lib/archsight/web/public/vue/PageView-DzKj212I.js +1 -0
- data/lib/archsight/web/public/vue/{QueryError-DzGMgvyb.js → QueryError-CTVAL1Tm.js} +1 -1
- data/lib/archsight/web/public/vue/{ResourceList-Cr9ExUDn.js → ResourceList-CRt_FpfS.js} +1 -1
- data/lib/archsight/web/public/vue/{SearchResults-D6tx3Atc.js → SearchResults-BMwBz4BB.js} +1 -1
- data/lib/archsight/web/public/vue/{WikiPage-BhaaveRq.js → WikiPage-DSEL2gmd.js} +1 -1
- data/lib/archsight/web/public/vue/{index-le1guGp1.js → index-JZkWwfYg.js} +2 -2
- data/lib/archsight/web/public/vue.html +1 -1
- metadata +24 -14
- data/lib/archsight/web/public/vue/PageView-B3SnDw9S.js +0 -1
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "base"
|
|
4
|
+
require_relative "../summary"
|
|
5
|
+
|
|
6
|
+
class Archsight::MCP::SummaryTool < FastMcp::Tool
|
|
7
|
+
tool_name "summary"
|
|
8
|
+
|
|
9
|
+
description <<~DESC.gsub("\n", " ").strip
|
|
10
|
+
Explain a resource in context from its name: what it is (kind, layer, description, key facts) and how it fits in,
|
|
11
|
+
as a short markdown summary. Which relations are followed depends on the layer of the resource (the lens):
|
|
12
|
+
motivation = stakeholders, parent goals and refinements, requirements, evidence; strategy = what realizes and
|
|
13
|
+
serves it; business = people, controls, products and contracts; application = interfaces, what it runs on, what
|
|
14
|
+
depends on it, owners; technology = what it is built on, what runs on it, where it is, owners; implementation =
|
|
15
|
+
plateau, gap and work package chain.
|
|
16
|
+
|
|
17
|
+
Every resource in the summary is a link [[Kind/Name]]: take kind and name from it for the next call. A group
|
|
18
|
+
that is cut off says how many more there are and the exact relations(...) call that lists them. Empty groups are
|
|
19
|
+
not shown. A closing section points to the other layers that have related resources.
|
|
20
|
+
|
|
21
|
+
EXAMPLES:
|
|
22
|
+
name="Backup" - finds the resource of that name in any kind; several matches come back as a list to choose from
|
|
23
|
+
kind="MotivationRequirement", name="R-7" - motivation lens: stakeholders, refinements, realized by, evidence
|
|
24
|
+
kind="ApplicationComponent", name="checkout" - application lens: interfaces, runs on, used by, owners
|
|
25
|
+
kind="TechnologyNode", name="node-1" - technology lens: runs on it, location, owners
|
|
26
|
+
kind="BusinessProcess", name="Billing", lens="application" - the same resource through another layer's lens
|
|
27
|
+
TYPICAL FLOW: query to find the name (or pass it directly), summary for the overview, then relations or
|
|
28
|
+
analyze_resource for details. PITFALLS: the name is exact and case-sensitive (a close one is suggested); per_section
|
|
29
|
+
only widens the lists, the summary stays bounded; lenses can be tuned per layer by a Config of type summary.
|
|
30
|
+
DESC
|
|
31
|
+
arguments do
|
|
32
|
+
required(:name).filled(:string).description(
|
|
33
|
+
"Name of the resource (or one of its aliases). Case-sensitive; without kind every kind is searched."
|
|
34
|
+
)
|
|
35
|
+
optional(:kind).filled(:string).description("Kind of the resource, to tell apart equal names, e.g. ApplicationComponent")
|
|
36
|
+
optional(:lens).filled(:string).description(
|
|
37
|
+
"View the resource through another layer's lens: #{Archsight::Resources::LAYERS.join(", ")}. Default: its own layer."
|
|
38
|
+
)
|
|
39
|
+
optional(:per_section).filled(:integer).description(
|
|
40
|
+
"Resources listed per relation group (1-20, default 5). The overall size stays capped."
|
|
41
|
+
)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def call(name:, kind: nil, lens: nil, per_section: 5)
|
|
45
|
+
return error("Unknown lens: #{lens}. Use one of #{Archsight::Resources::LAYERS.join(", ")}") if lens && !Archsight::Resources::LAYERS.include?(lens)
|
|
46
|
+
return error("Unknown resource kind: #{kind}") if kind && !Archsight::Resources[kind]
|
|
47
|
+
|
|
48
|
+
found = resolve(name, kind)
|
|
49
|
+
return not_found(name, kind) if found.empty?
|
|
50
|
+
return ambiguous(name, found) if found.length > 1
|
|
51
|
+
|
|
52
|
+
summarize(found.first, lens, per_section)
|
|
53
|
+
rescue StandardError => e
|
|
54
|
+
error("#{e.class}: #{e.message}")
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
private
|
|
58
|
+
|
|
59
|
+
def summarize(instance, lens, per_section)
|
|
60
|
+
info = Archsight::MCP.source_info(instance)
|
|
61
|
+
markdown = Archsight::Summary::Builder.new(Archsight::MCP.db, per_section: per_section)
|
|
62
|
+
.call(instance, lens_layer: lens, source: info)
|
|
63
|
+
JSON.pretty_generate({
|
|
64
|
+
kind: instance.klass,
|
|
65
|
+
name: instance.name,
|
|
66
|
+
layer: instance.class.layer,
|
|
67
|
+
lens: lens || instance.class.layer
|
|
68
|
+
}.merge(info).merge(summary: markdown))
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# The resources called `name` (an alias counts, then the same name in another letter case), of `kind` or of any kind
|
|
72
|
+
def resolve(name, kind)
|
|
73
|
+
db = Archsight::MCP.db
|
|
74
|
+
kinds = kind ? [kind] : db.instances.keys.map { |klass| klass.to_s.split("::").last }
|
|
75
|
+
[
|
|
76
|
+
-> { kinds.filter_map { |k| db.instance_by_kind(k, name) } },
|
|
77
|
+
-> { kinds.filter_map { |k| db.instance_by_alias(k, name) } },
|
|
78
|
+
-> { kinds.flat_map { |k| db.instances_by_kind(k).values.select { |i| i.name.to_s.casecmp?(name) } } }
|
|
79
|
+
].each do |attempt|
|
|
80
|
+
found = attempt.call.uniq
|
|
81
|
+
return found unless found.empty?
|
|
82
|
+
end
|
|
83
|
+
[]
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def ambiguous(name, found)
|
|
87
|
+
candidates = found.sort_by { |i| [i.klass, i.name] }.map do |i|
|
|
88
|
+
{ kind: i.klass, name: i.name, link: "[[#{i.klass}/#{i.name}]]", description: Archsight::MCP.extract_description(i) }
|
|
89
|
+
end
|
|
90
|
+
JSON.pretty_generate({
|
|
91
|
+
ambiguous: true,
|
|
92
|
+
message: "#{found.length} resources are called #{name}; call summary again with kind set to one of them",
|
|
93
|
+
candidates: candidates
|
|
94
|
+
})
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def not_found(name, kind)
|
|
98
|
+
suggestions = Archsight::MCP.suggest(name, kind: kind)
|
|
99
|
+
message = ["Resource not found: #{[kind, name].compact.join("/")}", Archsight::MCP.did_you_mean(suggestions)].compact.join(". ")
|
|
100
|
+
JSON.pretty_generate({ error: "Error", message: message, suggestions: suggestions })
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def error(message)
|
|
104
|
+
JSON.pretty_generate({ error: "Error", message: message })
|
|
105
|
+
end
|
|
106
|
+
end
|
data/lib/archsight/mcp.rb
CHANGED
|
@@ -3,5 +3,7 @@
|
|
|
3
3
|
require_relative "mcp/base"
|
|
4
4
|
require_relative "mcp/query_tool"
|
|
5
5
|
require_relative "mcp/analyze_resource_tool"
|
|
6
|
+
require_relative "mcp/relations_tool"
|
|
7
|
+
require_relative "mcp/summary_tool"
|
|
6
8
|
require_relative "mcp/resource_doc_tool"
|
|
7
9
|
require_relative "mcp/execute_analysis_tool"
|
data/lib/archsight/query/ast.rb
CHANGED
|
@@ -93,6 +93,34 @@ module Archsight::Query::AST
|
|
|
93
93
|
end
|
|
94
94
|
end
|
|
95
95
|
|
|
96
|
+
# Free-text condition: text =~ "pattern", text: "pattern", text(key, key/*) =~ "pattern". Matches when a string
|
|
97
|
+
# annotation (all of them, or the ones named by `keys`, which may end in a `*` wildcard) contains the pattern.
|
|
98
|
+
class TextCondition < Node
|
|
99
|
+
attr_reader :keys, :operator, :value
|
|
100
|
+
|
|
101
|
+
def initialize(keys, operator, value)
|
|
102
|
+
@keys = keys # Array of String (annotation keys or key patterns), or nil for every annotation
|
|
103
|
+
@operator = operator # "=~"
|
|
104
|
+
@value = value # StringValue or RegexValue
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# The compiled pattern, built once per query (every resource is checked against it)
|
|
108
|
+
def regexp
|
|
109
|
+
@regexp ||= Archsight::Query::AST.regexp_for(value)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# The key patterns as regular expressions (`*` = any run of characters), nil = every key
|
|
113
|
+
def key_patterns
|
|
114
|
+
return nil unless keys
|
|
115
|
+
|
|
116
|
+
@key_patterns ||= keys.map { |key| Regexp.new("\\A#{Regexp.escape(key).gsub("\\*", ".+")}\\z") }
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def accept(visitor)
|
|
120
|
+
visitor.visit_text_condition(self)
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
96
124
|
# Kind condition: kind == "SomeKind" or kind =~ "pattern"
|
|
97
125
|
class KindCondition < Node
|
|
98
126
|
attr_reader :operator, :value
|
|
@@ -143,6 +143,8 @@ class Archsight::Query::Evaluator
|
|
|
143
143
|
evaluate_annotation_exists_condition(node, instance)
|
|
144
144
|
when Archsight::Query::AST::AnnotationInCondition
|
|
145
145
|
evaluate_annotation_in_condition(node, instance)
|
|
146
|
+
when Archsight::Query::AST::TextCondition
|
|
147
|
+
Archsight::Query::TextSearch.matches?(instance, node)
|
|
146
148
|
when Archsight::Query::AST::KindCondition
|
|
147
149
|
evaluate_kind_condition(node, instance)
|
|
148
150
|
when Archsight::Query::AST::KindInCondition
|
|
@@ -245,8 +245,8 @@ class Archsight::Query::Lexer
|
|
|
245
245
|
|
|
246
246
|
# Allow letters, digits, underscores, hyphens, slashes, and dots in identifiers
|
|
247
247
|
# This supports annotation paths like "activity/status" and "scc/language/Go/loc"
|
|
248
|
-
# and resource names like "teleport.e"
|
|
249
|
-
while @position < @input.length && @input[@position] =~ %r{[a-zA-Z0-9_
|
|
248
|
+
# and resource names like "teleport.e"; `*` is for key patterns such as text(link/*)
|
|
249
|
+
while @position < @input.length && @input[@position] =~ %r{[a-zA-Z0-9_\-/.*]}
|
|
250
250
|
value += @input[@position]
|
|
251
251
|
@position += 1
|
|
252
252
|
end
|
|
@@ -388,6 +388,8 @@ class Archsight::Query::Parser
|
|
|
388
388
|
path = current_token.value
|
|
389
389
|
advance
|
|
390
390
|
|
|
391
|
+
return parse_text_condition if path == "text" && text_condition_ahead?
|
|
392
|
+
|
|
391
393
|
# Check if this is followed by an operator (annotation condition),
|
|
392
394
|
# a question mark (existence check), or a bare identifier (name shortcut)
|
|
393
395
|
if %i[EQ NEQ MATCH GT LT GTE LTE IN].include?(current_token.type)
|
|
@@ -403,6 +405,49 @@ class Archsight::Query::Parser
|
|
|
403
405
|
end
|
|
404
406
|
end
|
|
405
407
|
|
|
408
|
+
# `text` starts a free-text condition when `=~`, `:` plus a value, or a key list in parentheses follows;
|
|
409
|
+
# otherwise it is the bare word "text" (a name search)
|
|
410
|
+
def text_condition_ahead?
|
|
411
|
+
case current_token.type
|
|
412
|
+
when :MATCH, :LPAREN then true
|
|
413
|
+
when :COLON then %i[STRING REGEX].include?(peek_token&.type)
|
|
414
|
+
else false
|
|
415
|
+
end
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
# text =~ "x" | text: "x" | text(architecture/description, link/*) =~ "x"
|
|
419
|
+
def parse_text_condition
|
|
420
|
+
keys = nil
|
|
421
|
+
if current_token.type == :LPAREN
|
|
422
|
+
advance
|
|
423
|
+
keys = parse_text_keys
|
|
424
|
+
expect(:RPAREN)
|
|
425
|
+
end
|
|
426
|
+
|
|
427
|
+
raise Archsight::Query::ParseError.new("Expected =~ or : after text", position: current_token.position, source: nil) unless %i[MATCH COLON].include?(current_token.type)
|
|
428
|
+
|
|
429
|
+
advance
|
|
430
|
+
|
|
431
|
+
value_token = current_token
|
|
432
|
+
value = parse_value
|
|
433
|
+
check_value("=~", value, value_token)
|
|
434
|
+
Archsight::Query::AST::TextCondition.new(keys, "=~", value)
|
|
435
|
+
end
|
|
436
|
+
|
|
437
|
+
def parse_text_keys
|
|
438
|
+
keys = []
|
|
439
|
+
loop do
|
|
440
|
+
raise Archsight::Query::ParseError.new("Expected an annotation key in text(...)", position: current_token.position, source: nil) unless %i[IDENTIFIER STRING].include?(current_token.type)
|
|
441
|
+
|
|
442
|
+
keys << current_token.value
|
|
443
|
+
advance
|
|
444
|
+
break unless current_token.type == :COMMA
|
|
445
|
+
|
|
446
|
+
advance
|
|
447
|
+
end
|
|
448
|
+
keys
|
|
449
|
+
end
|
|
450
|
+
|
|
406
451
|
# Names contain colons (`Archsight:CLI`, `ITGS:A001`). A bare name written without spaces around its colons is
|
|
407
452
|
# one word: `ApplicationService:ITGS:A001` is the kind and the name `ITGS:A001`.
|
|
408
453
|
def glue_name(first)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "ast"
|
|
4
|
+
|
|
5
|
+
# Free-text search over the string annotations of a resource (`text =~ "x"`), shared by the evaluator and by the
|
|
6
|
+
# MCP query tool, which shows where the text was found.
|
|
7
|
+
module Archsight::Query::TextSearch
|
|
8
|
+
SNIPPET_WIDTH = 60
|
|
9
|
+
|
|
10
|
+
class << self
|
|
11
|
+
# Yields [key, value, MatchData] for every string annotation of `instance` the condition matches
|
|
12
|
+
def each_match(instance, condition, &block)
|
|
13
|
+
return enum_for(:each_match, instance, condition) unless block
|
|
14
|
+
|
|
15
|
+
regex = condition.regexp
|
|
16
|
+
keys = condition.key_patterns
|
|
17
|
+
instance.annotations.each do |key, value|
|
|
18
|
+
next unless value.is_a?(String)
|
|
19
|
+
next if keys&.none? { |pattern| pattern.match?(key) }
|
|
20
|
+
|
|
21
|
+
match = regex.match(value)
|
|
22
|
+
block.call(key, value, match) if match
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def matches?(instance, condition)
|
|
27
|
+
!each_match(instance, condition).first.nil?
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# A short single-line excerpt of `value` around the match
|
|
31
|
+
def snippet(value, match, width: SNIPPET_WIDTH)
|
|
32
|
+
from = [match.begin(0) - width, 0].max
|
|
33
|
+
to = [match.end(0) + width, value.length].min
|
|
34
|
+
text = value[from...to].gsub(/\s+/, " ").strip
|
|
35
|
+
"#{"…" if from.positive?}#{text}#{"…" if to < value.length}"
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
data/lib/archsight/query.rb
CHANGED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "diagram"
|
|
4
|
+
require_relative "helpers/diagram_blocks"
|
|
5
|
+
require_relative "helpers/asset_images"
|
|
6
|
+
|
|
7
|
+
module Archsight
|
|
8
|
+
# Estimated reading time of a markdown page: its words plus the diagrams (fenced ```asd blocks and embedded
|
|
9
|
+
# .asd files), which take longer the more nodes and edges they have.
|
|
10
|
+
module ReadingTime
|
|
11
|
+
WORDS_PER_MINUTE = 200
|
|
12
|
+
CODE_WEIGHT = 0.5 # code is read, but slower to count: every code word counts this much
|
|
13
|
+
SECONDS_PER_DIAGRAM = 10
|
|
14
|
+
SECONDS_PER_NODE = 3
|
|
15
|
+
SECONDS_PER_EDGE = 2
|
|
16
|
+
|
|
17
|
+
FENCE = /^[ \t]*(```|~~~)[^\n]*\n.*?^[ \t]*\1[ \t]*$/m
|
|
18
|
+
WORD = /\p{L}[\p{L}\p{N}'’-]*|\p{N}+/
|
|
19
|
+
MARKUP = /!\[[^\]]*\]\([^)]*\)|<[^>]+>|\{[a-z]+:[^}]*\}|https?:\/\/\S+/
|
|
20
|
+
|
|
21
|
+
# @return [Hash] `{ minutes:, words:, diagrams: }`; minutes is rounded up, at least 1
|
|
22
|
+
def self.estimate(markdown, base_dir: nil, resources_dir: nil, includes: nil)
|
|
23
|
+
markdown = markdown.to_s
|
|
24
|
+
prose, code = split(markdown)
|
|
25
|
+
words = count(prose)
|
|
26
|
+
sources = Helpers::DiagramBlocks.sources(markdown) + embedded(markdown, base_dir, resources_dir)
|
|
27
|
+
seconds = (words + (count(code) * CODE_WEIGHT)) * 60.0 / WORDS_PER_MINUTE
|
|
28
|
+
seconds += sources.sum { |source| diagram_seconds(source, includes) }
|
|
29
|
+
{ minutes: [(seconds / 60.0).ceil, 1].max, words: words, diagrams: sources.size }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Splits the markdown into prose and the text of non-diagram code blocks (diagram blocks are counted separately).
|
|
33
|
+
def self.split(markdown)
|
|
34
|
+
code = []
|
|
35
|
+
prose = markdown.gsub(FENCE) do |block|
|
|
36
|
+
code << block unless block.match?(/\A[ \t]*(?:```|~~~)asd\b/)
|
|
37
|
+
" "
|
|
38
|
+
end
|
|
39
|
+
[prose.gsub(MARKUP, " "), code.join("\n")]
|
|
40
|
+
end
|
|
41
|
+
private_class_method :split
|
|
42
|
+
|
|
43
|
+
def self.count(text)
|
|
44
|
+
text.scan(WORD).size
|
|
45
|
+
end
|
|
46
|
+
private_class_method :count
|
|
47
|
+
|
|
48
|
+
def self.embedded(markdown, base_dir, resources_dir)
|
|
49
|
+
return [] unless resources_dir
|
|
50
|
+
|
|
51
|
+
Helpers::AssetImages.asd_files(markdown, base_dir: base_dir, resources_dir: resources_dir).filter_map do |_path, file|
|
|
52
|
+
source = File.read(file, encoding: "UTF-8") if File.size(file) <= Helpers::AssetImages::MAX_ASD
|
|
53
|
+
source if source&.valid_encoding?
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
private_class_method :embedded
|
|
57
|
+
|
|
58
|
+
def self.diagram_seconds(source, includes)
|
|
59
|
+
graph = Diagram::Graph.build(Diagram.expand(source, includes: includes).statements)
|
|
60
|
+
SECONDS_PER_DIAGRAM + (graph.nodes_by_id.size * SECONDS_PER_NODE) + (graph.edges.size * SECONDS_PER_EDGE)
|
|
61
|
+
rescue Diagram::Error
|
|
62
|
+
SECONDS_PER_DIAGRAM
|
|
63
|
+
end
|
|
64
|
+
private_class_method :diagram_seconds
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -195,6 +195,7 @@ module Archsight
|
|
|
195
195
|
def initialize(raw, path_ref)
|
|
196
196
|
@raw = raw
|
|
197
197
|
@path_ref = path_ref
|
|
198
|
+
@merged_refs = [] # : Array[LineReference]
|
|
198
199
|
@references = []
|
|
199
200
|
# Auto-discover annotation keys
|
|
200
201
|
return unless annotations
|
|
@@ -372,6 +373,17 @@ module Archsight
|
|
|
372
373
|
merged = Archsight::Helpers.deep_merge(@raw, inst.raw)
|
|
373
374
|
union_list_annotations!(merged, inst.raw)
|
|
374
375
|
@raw = merged
|
|
376
|
+
@merged_refs << inst.path_ref
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
# Every document this resource is made of (the first one, then the ones merged into it), as LineReferences
|
|
380
|
+
def source_refs
|
|
381
|
+
[path_ref, *@merged_refs].compact.uniq { |ref| [ref.path, ref.line_no] }
|
|
382
|
+
end
|
|
383
|
+
|
|
384
|
+
# True when an importer or generator wrote (part of) the resource: it carries a `generated/script` annotation
|
|
385
|
+
def generated?
|
|
386
|
+
!annotations["generated/script"].to_s.empty?
|
|
375
387
|
end
|
|
376
388
|
|
|
377
389
|
# Annotations hold strings, which replace each other on merge. The values of a list annotation (tags, aliases)
|
|
@@ -34,11 +34,16 @@ class Archsight::Resources::BusinessContract < Archsight::Resources::Base
|
|
|
34
34
|
- It is `agreedBy` its parties: the actual organisations (the customer, the provider), not a generic role
|
|
35
35
|
- It is `composedOf` its parts: call-offs, SLAs and amendments, which are contracts themselves (no cycles)
|
|
36
36
|
- It `covers` what it obliges the provider to deliver: equipment, nodes, technology and application services
|
|
37
|
+
- It `stipulates` the `MotivationRequirement`s and `MotivationConstraint`s it makes binding: the legal basis of
|
|
38
|
+
an obligation. Link them instead of restating sizes, availability or response times in the description. A
|
|
39
|
+
requirement the provider derives itself (a design that refines a contractual obligation) is not stipulated by
|
|
40
|
+
a contract, it is `refinedBy`-linked from the stipulated requirement it refines. A requirement can be stipulated by several
|
|
41
|
+
contracts (a framework and a call-off)
|
|
37
42
|
- It is `realizedThrough` the `ImplementationDeliverable` that fulfils it; the `ImplementationWorkPackage` that
|
|
38
43
|
`realizes` the deliverable `affects` the equipment it installs
|
|
39
44
|
|
|
40
45
|
The other side shows these as incoming relations: the contracts an actor agreed, what covers a piece of
|
|
41
|
-
equipment or a service, the contract a deliverable fulfils.
|
|
46
|
+
equipment or a service, the contract a deliverable fulfils, and on a requirement the contracts that stipulate it.
|
|
42
47
|
MD
|
|
43
48
|
|
|
44
49
|
icon "journal-page"
|
|
@@ -68,5 +73,7 @@ class Archsight::Resources::BusinessContract < Archsight::Resources::Base
|
|
|
68
73
|
relation :covers, :technologyNodes, :TechnologyNode
|
|
69
74
|
relation :covers, :technologyServices, :TechnologyService
|
|
70
75
|
relation :covers, :applicationServices, :ApplicationService
|
|
76
|
+
relation :stipulates, :motivationRequirements, :MotivationRequirement
|
|
77
|
+
relation :stipulates, :motivationConstraints, :MotivationConstraint
|
|
71
78
|
relation :realizedThrough, :implementationDeliverables, :ImplementationDeliverable
|
|
72
79
|
end
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "../summary/lens"
|
|
4
|
+
|
|
3
5
|
# Config holds settings of a feature of the tool, kept with the model so they are shared and versioned like it
|
|
4
6
|
class Archsight::Resources::Config < Archsight::Resources::Base
|
|
5
7
|
include_annotations :architecture
|
|
@@ -22,10 +24,29 @@ class Archsight::Resources::Config < Archsight::Resources::Base
|
|
|
22
24
|
| `config/type` | Settings | Used by |
|
|
23
25
|
|---------------|----------|---------|
|
|
24
26
|
| `pdf` | `pdf/*`: colours, fonts, logo, header and footer | [PDF export](/doc/pdf-export) |
|
|
27
|
+
| `summary` | `summary/lens-<layer>`: what the MCP `summary` tool follows per layer | MCP `summary` tool |
|
|
25
28
|
|
|
26
29
|
A document picks a different Config of the type with the tag `pdf:template:<name>`; without a tag the one named
|
|
27
30
|
`default` is used, and without any the export has a neutral built-in look.
|
|
28
31
|
|
|
32
|
+
## Summary lenses
|
|
33
|
+
|
|
34
|
+
The MCP `summary` tool explains a resource through a lens chosen by its kind or layer. A Config of type `summary`
|
|
35
|
+
(the one named `default`) replaces the built-in lens of a layer with `summary/lens-<layer>` (`motivation`, `strategy`,
|
|
36
|
+
`implementation`, `business`, `application`, `technology`, `other`) and the one of a single kind with
|
|
37
|
+
`summary/lens-<Kind>` (for example `summary/lens-BusinessActor`); the kind wins over the layer. The built-in lenses
|
|
38
|
+
end with `in mentions, depicts: Documented in` (the pages that describe the resource); a lens of your own has to
|
|
39
|
+
list it to keep that section. One section per line,
|
|
40
|
+
`<out|in> <verb>[, <verb>...] [depth=N][: <title>]`; `out` = the resource declares the relation, `in` = the other
|
|
41
|
+
resource points at it, `*` = every verb:
|
|
42
|
+
|
|
43
|
+
```yaml
|
|
44
|
+
summary/lens-application: |
|
|
45
|
+
out exposes: Interfaces
|
|
46
|
+
in dependsOn: Used by
|
|
47
|
+
out servedBy depth=2: Runs on
|
|
48
|
+
```
|
|
49
|
+
|
|
29
50
|
## PDF settings
|
|
30
51
|
|
|
31
52
|
- **Colours** (`pdf/color-*`) are hex values (`#0b3d91`). `primary` is used for headings, the cover band and
|
|
@@ -139,6 +160,13 @@ class Archsight::Resources::Config < Archsight::Resources::Base
|
|
|
139
160
|
sidebar: false,
|
|
140
161
|
validator: ->(value) { Archsight::Resources::Config.keep_space_error(value) }
|
|
141
162
|
|
|
163
|
+
annotation "summary/lens-*",
|
|
164
|
+
description: "Lens of a layer (summary/lens-application) or of one kind (summary/lens-BusinessActor) for the " \
|
|
165
|
+
"MCP summary tool: one section per line, `<out|in> <verb>[, <verb>] [depth=N][: <title>]`",
|
|
166
|
+
title: "Summary lens",
|
|
167
|
+
sidebar: false,
|
|
168
|
+
validator: ->(value) { Archsight::Summary::Lens.parse_error(value) }
|
|
169
|
+
|
|
142
170
|
HEADER_PARTS = %w[id version date owner].freeze
|
|
143
171
|
HEADING_LEVELS = (1..6).to_a.freeze
|
|
144
172
|
KEEP_SPACE = /\A([1-6]):(\d{1,3})%?\z/
|
|
@@ -28,6 +28,7 @@ class Archsight::Resources::ImplementationWorkPackage < Archsight::Resources::Ba
|
|
|
28
28
|
|
|
29
29
|
- `ownedBy` the accountable actor or role, `performedBy` the actors or roles that carry it out
|
|
30
30
|
- `realizes` deliverables (its results), requirements and goals
|
|
31
|
+
- `plans` the requirements it will meet but does not yet: the "Requirements" table and `requirements` blocks show them as "planned" (`realizes` shows "implemented"); move them to `realizes` when the work is done
|
|
31
32
|
- `affects` the assets it changes, for example the `TechnologyEquipment` a project installs; the assessments (risks, findings) it treats are `mitigatedBy` it (written on the assessment)
|
|
32
33
|
- `triggers` the work packages that follow it; an `ImplementationEvent` can trigger it
|
|
33
34
|
- A `ImplementationGap` is `closedBy` it
|
|
@@ -74,6 +75,7 @@ class Archsight::Resources::ImplementationWorkPackage < Archsight::Resources::Ba
|
|
|
74
75
|
relation :performedBy, :businessRoles, :BusinessRole
|
|
75
76
|
relation :realizes, :implementationDeliverables, :ImplementationDeliverable
|
|
76
77
|
relation :realizes, :motivationRequirements, :MotivationRequirement
|
|
78
|
+
relation :plans, :motivationRequirements, :MotivationRequirement
|
|
77
79
|
relation :realizes, :goals, :MotivationGoal
|
|
78
80
|
relation :affects, :businessProcesses, :BusinessProcess
|
|
79
81
|
relation :affects, :applicationComponents, :ApplicationComponent
|
|
@@ -42,6 +42,15 @@ class Archsight::Resources::MotivationRequirement < Archsight::Resources::Base
|
|
|
42
42
|
the requirement answers. The stakeholder is `representedBy` the actor or role behind it, so the chain reaches the
|
|
43
43
|
actual organisation that asked for the requirement.
|
|
44
44
|
|
|
45
|
+
## Refinement
|
|
46
|
+
|
|
47
|
+
A requirement is either taken as it is or made more concrete: the catalogue requirement (an IT-Grundschutz
|
|
48
|
+
building block requirement, a C5 criterion) is `refinedBy` the requirements derived from it, one or several, in
|
|
49
|
+
any depth. The relation is written on the more abstract requirement and points down, like `composedOf`; the
|
|
50
|
+
derived requirement shows the catalogue requirement as incoming "refines". Everything that realizes, plans or
|
|
51
|
+
satisfies the derived requirement thereby answers to the catalogue requirement as well. A catalogue requirement
|
|
52
|
+
taken as it is needs no relation: link it directly. The chain must not form a cycle (`archsight lint`).
|
|
53
|
+
|
|
45
54
|
## Security and risk modelling
|
|
46
55
|
|
|
47
56
|
- **Control measure:** `requirement/type` `control-measure` is a measure that a control objective
|
|
@@ -78,6 +87,7 @@ class Archsight::Resources::MotivationRequirement < Archsight::Resources::Base
|
|
|
78
87
|
title: "Story",
|
|
79
88
|
format: :markdown
|
|
80
89
|
|
|
90
|
+
relation :refinedBy, :motivationRequirements, :MotivationRequirement
|
|
81
91
|
relation :realizes, :outcomes, :MotivationOutcome
|
|
82
92
|
relation :realizes, :motivationPrinciples, :MotivationPrinciple
|
|
83
93
|
end
|
|
@@ -47,6 +47,13 @@ class Archsight::Resources::TechnologyDevice < Archsight::Resources::Base
|
|
|
47
47
|
- Who uses it is the team or role (`servedBy`), not a person; a client device needs no room, `locatedAt` an
|
|
48
48
|
office is optional
|
|
49
49
|
|
|
50
|
+
## CPU generation
|
|
51
|
+
|
|
52
|
+
`device/arch` is the instruction set; `device/cpu` is the microarchitecture or generation ("Ice Lake",
|
|
53
|
+
"Zen 5") and `device/cpuModel` the exact model number. Hosts of one generation share the CPU features a VM can
|
|
54
|
+
be given and the live-migration domain, so `device/cpu == "Ice Lake"` lists them. The vendor product of the
|
|
55
|
+
machine stays in `device/model`.
|
|
56
|
+
|
|
50
57
|
## Not this kind
|
|
51
58
|
|
|
52
59
|
- A VM, a Kubernetes node or a host role is a `TechnologyNode`
|
|
@@ -115,6 +122,13 @@ class Archsight::Resources::TechnologyDevice < Archsight::Resources::Base
|
|
|
115
122
|
title: "Architecture",
|
|
116
123
|
enum: %w[x86_64 arm64 riscv64 other],
|
|
117
124
|
filter: :word
|
|
125
|
+
annotation "device/cpu",
|
|
126
|
+
description: "CPU microarchitecture or generation, e.g. Ice Lake, Sierra Forest, Zen 5",
|
|
127
|
+
title: "CPU",
|
|
128
|
+
filter: :word
|
|
129
|
+
annotation "device/cpuModel",
|
|
130
|
+
description: "Exact CPU model number, e.g. Xeon Gold 6338",
|
|
131
|
+
title: "CPU Model"
|
|
118
132
|
annotation "device/ownership",
|
|
119
133
|
description: "Who owns the device",
|
|
120
134
|
title: "Ownership",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# TechnologyEquipment represents racks, fabrics and physical clusters inside a facility
|
|
4
4
|
class Archsight::Resources::TechnologyEquipment < Archsight::Resources::Base
|
|
5
|
-
include_annotations :git, :architecture
|
|
5
|
+
include_annotations :git, :architecture, :capacity
|
|
6
6
|
|
|
7
7
|
description <<~MD
|
|
8
8
|
Represents physical equipment inside a facility: racks, network fabrics, physical clusters.
|
|
@@ -49,6 +49,8 @@ class Archsight::Resources::TechnologyEquipment < Archsight::Resources::Base
|
|
|
49
49
|
The devices of a partition are normally served by the same team; `archsight lint` warns when one is not
|
|
50
50
|
- A `BusinessContract` `covers` the equipment it obliges the provider to deliver, and the `ImplementationWorkPackage` that
|
|
51
51
|
installs or changes it `affects` it
|
|
52
|
+
- `capacity/spareHosts` is the number of hosts of a site or delivered block held in reserve (n+1); it is a count,
|
|
53
|
+
not a machine, so it is not a flag on a `TechnologyDevice`. The source goes into a `link/*` annotation
|
|
52
54
|
MD
|
|
53
55
|
|
|
54
56
|
icon "cpu"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# TechnologyNode represents physical infrastructure (VMs, servers, Kubernetes nodes)
|
|
4
4
|
class Archsight::Resources::TechnologyNode < Archsight::Resources::Base
|
|
5
|
-
include_annotations :git, :architecture, :asset, :risk
|
|
5
|
+
include_annotations :git, :architecture, :asset, :risk, :capacity
|
|
6
6
|
|
|
7
7
|
description <<~MD
|
|
8
8
|
Represents physical infrastructure hosting application components.
|
|
@@ -54,6 +54,13 @@ class Archsight::Resources::TechnologyNode < Archsight::Resources::Base
|
|
|
54
54
|
A logical node (a host role, "the hypervisors of the platform") is `realizedBy` the `TechnologyDevice`s, the
|
|
55
55
|
physical machines, that make it up.
|
|
56
56
|
|
|
57
|
+
## Spare hosts
|
|
58
|
+
|
|
59
|
+
A host role or pool keeps hosts in reserve (n+1). The reserve is a count, not a machine: any host can take the
|
|
60
|
+
role and the actual spare changes, so `capacity/spareHosts` holds the number on the node (not a flag on a
|
|
61
|
+
`TechnologyDevice`) and a `link/*` annotation the source. "N hosts, of which K spare" is the devices the node is
|
|
62
|
+
`realizedBy` and this count.
|
|
63
|
+
|
|
57
64
|
## Concept and implementation
|
|
58
65
|
|
|
59
66
|
A node can `specialize` another node (ArchiMate specialization): the general node is the concept (a regional
|