@uipath/skills 1.206.0 → 1.206.1
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.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.cursor-plugin/plugin.json +1 -1
- package/CODEOWNERS +34 -7
- package/README.md +2 -2
- package/package.json +2 -2
- package/skills/uipath-genome/SKILL.md +35 -88
- package/skills/uipath-genome/references/build-guide.md +61 -0
- package/skills/uipath-genome/references/completion-report-guide.md +93 -0
- package/skills/uipath-genome/references/composite-interactions-guide.md +39 -0
- package/skills/uipath-genome/references/configuration-questions-guide.md +68 -0
- package/skills/uipath-genome/references/execution-guide.md +45 -166
- package/skills/uipath-genome/references/execution-parts-guide.md +84 -17
- package/skills/uipath-genome/references/genome-reading-guide.md +153 -0
- package/skills/uipath-genome/references/live-application-guide.md +23 -9
- package/skills/uipath-genome/references/offline-definition-workarounds-guide.md +4 -4
- package/skills/uipath-genome/references/open-items-guide.md +3 -3
- package/skills/uipath-genome/references/package-doc-errata-guide.md +8 -0
- package/skills/uipath-genome/references/refactor-guide.md +38 -39
- package/skills/uipath-genome/references/selector-matching-guide.md +59 -0
- package/skills/uipath-genome/references/selector-translation-guide.md +13 -66
- package/skills/uipath-genome/references/selector-translation-sap-guide.md +7 -5
- package/skills/uipath-genome/references/selector-translation-web-guide.md +2 -2
- package/skills/uipath-genome/references/source-frameworks-guide.md +21 -0
- package/skills/uipath-genome/references/source-migration-guide.md +48 -19
- package/skills/uipath-genome/references/test-execution-guide.md +8 -7
- package/skills/uipath-genome/references/transactional-execution-guide.md +41 -13
- package/skills/uipath-genome/references/ui-target-migration-guide.md +12 -49
- package/skills/uipath-genome/references/ui-verification-guide.md +9 -1
- package/skills/uipath-maestro-case/SKILL.md +7 -7
- package/skills/uipath-maestro-case/references/evals/evals.json +5 -5
- package/skills/uipath-maestro-case/references/planning.md +5 -5
- package/skills/uipath-maestro-case/references/plugins/conditions/task-entry-conditions/planning.md +2 -2
- package/skills/uipath-maestro-case/references/plugins/sla/planning.md +1 -1
- package/skills/uipath-maestro-case/references/registry-discovery.md +3 -3
- package/skills/uipath-planner/SKILL.md +80 -199
- package/skills/uipath-planner/assets/templates/agent-sdd-template.md +17 -17
- package/skills/uipath-planner/assets/templates/api-workflow-sdd-template.md +15 -13
- package/skills/uipath-planner/assets/templates/bpmn-sdd-template.md +19 -19
- package/skills/uipath-planner/assets/templates/case-sdd-task-details-template.md +173 -0
- package/skills/uipath-planner/assets/templates/{case/case-sdd-template.md → case-sdd-template.md} +51 -229
- package/skills/uipath-planner/assets/templates/coded-app-sdd-template.md +16 -14
- package/skills/{uipath-genome → uipath-planner}/assets/templates/component-genome-template.md +9 -5
- package/skills/uipath-planner/assets/templates/flow-sdd-template.md +17 -15
- package/skills/{uipath-genome → uipath-planner}/assets/templates/process-genome-template.md +11 -7
- package/skills/uipath-planner/assets/templates/rpa-sdd-template.md +50 -73
- package/skills/uipath-planner/references/author/author-guide.md +119 -0
- package/skills/uipath-planner/references/author/genome-from-sdd-guide.md +36 -0
- package/skills/uipath-planner/references/author/scenario-proposal-guide.md +30 -0
- package/skills/uipath-planner/references/decompose/decompose-guide.md +223 -0
- package/skills/uipath-planner/references/{asdd-crosswalk-guide.md → design/asdd-crosswalk-guide.md} +6 -4
- package/skills/uipath-planner/references/{business-rules-guide.md → design/business-rules-guide.md} +3 -3
- package/skills/uipath-planner/references/design/caller-request-guide.md +92 -0
- package/skills/uipath-planner/references/design/case-data-and-time-guide.md +292 -0
- package/skills/uipath-planner/references/design/case-product-guide.md +243 -0
- package/skills/uipath-planner/references/design/case-review-and-conformance-guide.md +166 -0
- package/skills/uipath-planner/references/design/design-guide.md +296 -0
- package/skills/uipath-planner/references/{package-selection-guide.md → design/package-selection-guide.md} +16 -13
- package/skills/uipath-planner/references/{rpa-product-guide.md → design/rpa-product-guide.md} +23 -53
- package/skills/uipath-planner/references/design/scope-recommendation-guide.md +134 -0
- package/skills/uipath-planner/references/design/sdd-writing-guide.md +235 -0
- package/skills/uipath-planner/references/design/solution-composition-guide.md +153 -0
- package/skills/uipath-planner/references/edit/edit-guide.md +66 -0
- package/skills/uipath-planner/references/extract/extract-guide.md +230 -0
- package/skills/uipath-planner/references/extract/source-frameworks-guide.md +22 -0
- package/skills/uipath-planner/references/extract/uipath-non-rpa-signals-guide.md +121 -0
- package/skills/uipath-planner/references/extract/uipath-rpa-signals-guide.md +88 -0
- package/skills/uipath-planner/references/extract/uipath-source-guide.md +193 -0
- package/skills/uipath-planner/references/shared/component-placement-guide.md +99 -0
- package/skills/{uipath-genome/references → uipath-planner/references/shared}/defect-verification-guide.md +4 -4
- package/skills/{uipath-genome/references → uipath-planner/references/shared}/extracted-genome-guide.md +15 -14
- package/skills/uipath-planner/references/shared/extraction-parts-guide.md +66 -0
- package/skills/{uipath-genome/references → uipath-planner/references/shared}/genome-format-guide.md +63 -34
- package/skills/uipath-planner/references/{multi-skill-patterns-guide.md → shared/multi-skill-patterns-guide.md} +28 -27
- package/skills/uipath-planner/references/{pdd-analysis-guide.md → shared/pdd-analysis-guide.md} +27 -72
- package/skills/uipath-planner/references/{plan-and-tasks-format.md → shared/plan-and-tasks-format.md} +43 -67
- package/skills/uipath-planner/references/{platform-availability-guide.md → shared/platform-availability-guide.md} +56 -1
- package/skills/uipath-planner/references/shared/product-selection-guide.md +202 -0
- package/skills/{uipath-genome/references → uipath-planner/references/shared}/skill-mapping-guide.md +24 -4
- package/skills/uipath-planner/references/{tenant-library-search-guide.md → shared/tenant-library-search-guide.md} +10 -8
- package/skills/{uipath-genome/references → uipath-planner/references/shared}/transactional-shape-guide.md +39 -8
- package/skills/uipath-planner/scripts/check-genome.mjs +801 -0
- package/skills/uipath-planner/scripts/sdd-fingerprint.mjs +71 -0
- package/skills/uipath-planner/scripts/sdd-to-docx.mjs +87 -0
- package/skills/uipath-test/SKILL.md +3 -3
- package/version-manifest.json +1 -1
- package/skills/uipath-genome/CLAUDE.md +0 -85
- package/skills/uipath-genome/assets/examples/artemis-2-mission-monitor-genome.md +0 -126
- package/skills/uipath-genome/assets/examples/classify-document-and-create-validation-genome.md +0 -117
- package/skills/uipath-genome/assets/examples/invoice-processing-genome/exception-triage-agent-genome.md +0 -96
- package/skills/uipath-genome/assets/examples/invoice-processing-genome/invoice-extraction-genome.md +0 -128
- package/skills/uipath-genome/assets/examples/invoice-processing-genome/invoice-orchestration-genome.md +0 -115
- package/skills/uipath-genome/assets/examples/invoice-processing-genome.md +0 -136
- package/skills/uipath-genome/assets/examples/purchase-requisition-entry-genome.md +0 -224
- package/skills/uipath-genome/assets/examples/salesforce-accounts-and-contacts-genome.md +0 -151
- package/skills/uipath-genome/references/authoring-guide.md +0 -98
- package/skills/uipath-genome/references/editing-guide.md +0 -57
- package/skills/uipath-genome/references/extraction-guide.md +0 -166
- package/skills/uipath-genome/references/extraction-parts-guide.md +0 -45
- package/skills/uipath-genome/references/parts-guide.md +0 -22
- package/skills/uipath-genome/references/uipath-source-guide.md +0 -404
- package/skills/uipath-genome/scripts/check-genome.py +0 -670
- package/skills/uipath-planner/assets/templates/case/sdd-viewer.html +0 -1530
- package/skills/uipath-planner/references/case/case-design-lane-guide.md +0 -327
- package/skills/uipath-planner/references/case/case-design-layers-guide.md +0 -503
- package/skills/uipath-planner/references/case/case-sdd-conformance-checklist.md +0 -123
- package/skills/uipath-planner/references/non-pdd-lane-guide.md +0 -196
- package/skills/uipath-planner/references/pdd-driven-lane-guide.md +0 -210
- package/skills/uipath-planner/references/product-selection-guide.md +0 -673
- package/skills/uipath-planner/references/sdd-generation-guide.md +0 -613
- package/skills/uipath-planner/scripts/docx-extract.ps1 +0 -59
- package/skills/uipath-planner/scripts/docx-extract.sh +0 -54
- package/skills/uipath-planner/scripts/sdd-to-docx.ps1 +0 -74
- package/skills/uipath-planner/scripts/sdd-to-docx.sh +0 -76
- /package/skills/uipath-planner/references/{attended-reauth-pattern-guide.md → design/attended-reauth-pattern-guide.md} +0 -0
|
@@ -1,670 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""Checks a genome written by the uipath-genome skill, and its Source Map's step tables against the source export.
|
|
3
|
-
|
|
4
|
-
Usage:
|
|
5
|
-
check-genome.py component <genome.md> [--profile core|strict] [--expect TOKEN ...] [--source-map TOKEN ...]
|
|
6
|
-
check-genome.py process <genome.md> [--profile core|strict] [--skills SKILL ...] [--expect TOKEN ...]
|
|
7
|
-
check-genome.py tokens <pattern> --expect TOKEN ... [--min FRACTION] [--files N]
|
|
8
|
-
component and process also take: [--shape transactional|stub [--flows N] [--unit TOKEN ...]]
|
|
9
|
-
[--shape-checks gate|advisory] advisory: Transactional Shape findings
|
|
10
|
-
are graded by the strict profile only (a task that tests something else)
|
|
11
|
-
[--processes <inventory.json> --recordsets <recordsets.json>]
|
|
12
|
-
|
|
13
|
-
The skill runs it with --profile strict after writing or editing a genome. For a genome extracted through the
|
|
14
|
-
framework migration pack it adds the two files the pack's `data` command writes, and execution runs it so at
|
|
15
|
-
migration preflight against the export it resolved. The genome tasks under tests/tasks/uipath-genome/ grade
|
|
16
|
-
with this file.
|
|
17
|
-
|
|
18
|
-
Profiles:
|
|
19
|
-
core the genome contract a smoke test gates on: level and preamble, every section, valid skill names,
|
|
20
|
-
steps and criteria present, a Transactional Shape that is the stub or has flows that each name their
|
|
21
|
-
unit of work, Source Map tokens, expected facts; in an extracted genome (one with a Source Map), a
|
|
22
|
-
`### Steps` table with exactly one row per Workflow step.
|
|
23
|
-
strict core plus every mechanical format rule of genome-format-guide.md, transactional-shape-guide.md and
|
|
24
|
-
extracted-genome-guide.md: behavioural wording (no code-level tokens), configuration question kind
|
|
25
|
-
and default, bold step names, numbered acceptance criteria, the As-is table, exactly the outcome
|
|
26
|
-
rows rule 4 allows, split options named by letter with only their Requires and Changes cells,
|
|
27
|
-
complete for every unit and alternative unit, retry and consecutive-failure stop; step table cells
|
|
28
|
-
holding references only.
|
|
29
|
-
|
|
30
|
-
Export check (--processes and --recordsets, both required together):
|
|
31
|
-
--processes a list of {"id", "name", "recordset" (name or null), "calls": [{"calleeId", "recordset"}]}
|
|
32
|
-
--recordsets a list of {"id", "name"}; an entry with "drives": false is provenance, never a data set
|
|
33
|
-
In every step table: each source object is `Name` (id) with the id a process of that name, each data set
|
|
34
|
-
`Name` (id) with the id a data set of that name, and every row names at least one source object. A library
|
|
35
|
-
step's process that no built root reaches while a same-named copy is reachable is the wrong copy; a library
|
|
36
|
-
workflow nothing in the genome calls is a NOTE. The check reads no prose and derives nothing.
|
|
37
|
-
|
|
38
|
-
<genome.md> and <pattern> may be a quoted glob ("*-genome.md"): the file name is the agent's choice, only the
|
|
39
|
-
-genome.md suffix is a contract. component and process need exactly one match; tokens searches every match,
|
|
40
|
-
case-sensitively, like a file_contains criterion.
|
|
41
|
-
|
|
42
|
-
Exit 0 when every check passes; exit 1 with one line per failure.
|
|
43
|
-
"""
|
|
44
|
-
|
|
45
|
-
import argparse
|
|
46
|
-
import functools
|
|
47
|
-
import json
|
|
48
|
-
import re
|
|
49
|
-
import sys
|
|
50
|
-
from pathlib import Path
|
|
51
|
-
|
|
52
|
-
VALID_SKILLS = {
|
|
53
|
-
"uipath-rpa", "uipath-maestro-flow", "uipath-maestro-bpmn", "uipath-maestro-case",
|
|
54
|
-
"uipath-agents", "uipath-functions", "uipath-api-workflow", "uipath-coded-apps",
|
|
55
|
-
"uipath-connector-builder", "uipath-ixp", "uipath-process-mining", "uipath-mcp-servers",
|
|
56
|
-
"uipath-solution", "uipath-human-in-the-loop", "uipath-rules",
|
|
57
|
-
}
|
|
58
|
-
OPERATE_SKILLS = { # allowed in Platform Dependencies / Deployment, never in Build With or Components
|
|
59
|
-
"uipath-platform", "uipath-tasks", "uipath-test", "uipath-admin", "uipath-insights",
|
|
60
|
-
"uipath-troubleshoot", "uipath-governance", "uipath-review", "uipath-planner", "uipath-aops",
|
|
61
|
-
"uipath-automationhub", "uipath-feedback",
|
|
62
|
-
"uipath-activity-migrator", "uipath-knowledge-bundles", "uipath-vertical-solutions",
|
|
63
|
-
}
|
|
64
|
-
RETIRED_SKILLS = {"uipath-rpa-workflows", "uipath-coded-workflows", "uipath-coded-agents"}
|
|
65
|
-
|
|
66
|
-
COMPONENT_SECTIONS = [
|
|
67
|
-
"Overview", "Target Applications", "Build With", "Platform Dependencies", "Interface",
|
|
68
|
-
"Configuration Questions", "Workflow", "Business Rules", "Error Handling",
|
|
69
|
-
"Transactional Shape", "Acceptance Criteria", "Complexity", "Tags",
|
|
70
|
-
]
|
|
71
|
-
PROCESS_SECTIONS = [
|
|
72
|
-
"Overview", "Actors and Systems", "Components", "Process Map", "Handoffs",
|
|
73
|
-
"Platform Dependencies", "Configuration Questions", "Business Rules",
|
|
74
|
-
"Error Handling and Recovery", "Transactional Shape", "Acceptance Criteria", "Deployment",
|
|
75
|
-
"Complexity", "Tags",
|
|
76
|
-
]
|
|
77
|
-
# Code-level tokens that must not appear in the genome body (Source Map excluded).
|
|
78
|
-
BANNED_BODY_TOKENS = [
|
|
79
|
-
"InvokeWorkflowFile", "RetryScope", "TryCatch", "ReadRange", "AppendRange", "WriteRange",
|
|
80
|
-
"GetIMAPMailMessages", "SaveAttachments", "AddQueueItem", "ReadPDFText", "LogMessage",
|
|
81
|
-
"AndAlso", "OrElse", "dt_", "in_", "out_", ".xaml", "core.action", "core.logic",
|
|
82
|
-
"uipath.core.", "activityType", "JsInvoke",
|
|
83
|
-
]
|
|
84
|
-
OUTCOME_ROWS = {"Success", "Business exception", "System exception", "Postponed"}
|
|
85
|
-
# format guide § Population Matrix: minimum Workflow steps and Acceptance Criteria per complexity.
|
|
86
|
-
# core gates only on the floor every genome meets (the simple minimum); the per-complexity minimum is strict.
|
|
87
|
-
CORE_FLOOR = 3
|
|
88
|
-
MIN_STEPS_BY_COMPLEXITY = {"simple": 3, "medium": 5, "complex": 8}
|
|
89
|
-
MIN_CRITERIA_BY_COMPLEXITY = {"simple": 3, "medium": 5, "complex": 7}
|
|
90
|
-
SPLIT_OPTIONS = {"A", "B", "C"}
|
|
91
|
-
SPLIT_COLUMNS = ["unit of work", "option", "requires", "changes against as-is"]
|
|
92
|
-
STUB = "Not transactional"
|
|
93
|
-
# transactional shape guide rule 9: a flow with one side outside the genome names it instead of the table
|
|
94
|
-
EXTERNAL_SIDE = re.compile(r"Split options:(?:\*\*)? none\s*[—–-]+\s*the (consumer|producer) is outside this genome", re.I)
|
|
95
|
-
# extracted genome guide § Source Map: the step table
|
|
96
|
-
STEPS_COLUMNS = ["step", "source objects", "data sets", "captures", "notes"]
|
|
97
|
-
REFERENCE = re.compile(r"`([^`]+)`(?:\s*\(((?:[^()`]|`[^`]*`)*)\))?") # `Name`, `Name` (id), `Name` (id, locator)
|
|
98
|
-
TEMPLATES = Path(__file__).resolve().parent.parent / "assets" / "templates"
|
|
99
|
-
PLACEHOLDER = re.compile(r"\{[a-z][^}]*\}")
|
|
100
|
-
ONE_WORD = re.compile(r"\{[a-z]+\}")
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
class Report:
|
|
104
|
-
"""Collects findings; a strict finding is dropped under the core profile."""
|
|
105
|
-
|
|
106
|
-
def __init__(self, profile: str, shape_gates: bool = True):
|
|
107
|
-
self.profile = profile
|
|
108
|
-
self.shape_gates = shape_gates # --shape-checks advisory: Transactional Shape findings count as strict
|
|
109
|
-
self.errors: list[str] = []
|
|
110
|
-
|
|
111
|
-
def shape(self, message: str) -> None:
|
|
112
|
-
(self.core if self.shape_gates else self.strict)(message)
|
|
113
|
-
|
|
114
|
-
def core(self, message: str) -> None:
|
|
115
|
-
self.errors.append(message)
|
|
116
|
-
|
|
117
|
-
def strict(self, message: str) -> None:
|
|
118
|
-
if self.profile == "strict":
|
|
119
|
-
self.errors.append(message)
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
# --- markdown helpers --------------------------------------------------------------------------
|
|
123
|
-
|
|
124
|
-
def h2_positions(text: str) -> dict[str, int]:
|
|
125
|
-
return {m.group(1).strip(): m.start() for m in re.finditer(r"^## (.+)$", text, re.M)}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
def section_pos(pos: dict[str, int], name: str) -> int | None:
|
|
129
|
-
"""Position of the first heading that starts with name, any case ('Error Handling and Recovery'
|
|
130
|
-
counts as 'Error Handling'). The exact heading is a format rule, graded by strict."""
|
|
131
|
-
return next((p for h, p in pos.items() if h.lower().startswith(name.lower())), None)
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
def section_body(text: str, heading: str) -> str:
|
|
135
|
-
m = re.search(rf"^## {re.escape(heading)}\b[^\n]*$(.*?)(?=^## |\Z)", text, re.M | re.S | re.I)
|
|
136
|
-
return m.group(1) if m else ""
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
def complexity_of(text: str) -> str | None:
|
|
140
|
-
m = re.search(r"\b(simple|medium|complex)\b", section_body(text, "Complexity"), re.I)
|
|
141
|
-
return m.group(1).lower() if m else None
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
def body_without_source_map(text: str) -> str:
|
|
145
|
-
return re.split(r"^## Source Map\s*$", text, maxsplit=1, flags=re.M)[0]
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
def cells(row: str) -> list[str]:
|
|
149
|
-
return [c.strip() for c in row.strip().strip("|").split("|")]
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
def table_rows(block: str, header_start: str) -> list[list[str]]:
|
|
153
|
-
"""Data rows of the first markdown table in block whose header row starts with header_start."""
|
|
154
|
-
lines = block.splitlines()
|
|
155
|
-
for i, line in enumerate(lines):
|
|
156
|
-
if line.strip().startswith(header_start):
|
|
157
|
-
rows = []
|
|
158
|
-
for row in lines[i + 2:]:
|
|
159
|
-
if not row.strip().startswith("|"):
|
|
160
|
-
break
|
|
161
|
-
rows.append(cells(row))
|
|
162
|
-
return rows
|
|
163
|
-
return []
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
def flow_blocks(ts: str) -> list[tuple[str, str]]:
|
|
167
|
-
"""(name, body) per '### Flow N' block of the Transactional Shape."""
|
|
168
|
-
parts = re.split(r"^(### Flow\b.*)$", ts, flags=re.M)
|
|
169
|
-
return [(parts[i].lstrip("# ").split(":")[0].strip(), parts[i + 1]) for i in range(1, len(parts) - 1, 2)]
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
def workflow_steps(text: str) -> list[str]:
|
|
173
|
-
"""The numbers of the Workflow's top-level steps, in order."""
|
|
174
|
-
return re.findall(r"^(\d+)\.\s", section_body(text, "Workflow"), re.M)
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
def steps_table(text: str) -> tuple[list[str], list[list[str]]] | None:
|
|
178
|
-
"""(header cells, rows) of the Source Map's `### Steps` table; None when the Source Map has none."""
|
|
179
|
-
m = re.search(r"^### Steps\s*$(.*?)(?=^#{2,3} |\Z)", section_body(text, "Source Map"), re.M | re.S)
|
|
180
|
-
if not m:
|
|
181
|
-
return None
|
|
182
|
-
header = next((l for l in m.group(1).splitlines() if l.strip().startswith("|")), "")
|
|
183
|
-
return [c.lower() for c in cells(header)], table_rows(m.group(1), header.strip()) if header else []
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
def split_references(cell: str) -> list[str]:
|
|
187
|
-
"""The parts of a step table cell, split on '; ' outside backticks and parentheses."""
|
|
188
|
-
parts, part, tick, depth = [], "", False, 0
|
|
189
|
-
for ch in cell:
|
|
190
|
-
if ch == "`":
|
|
191
|
-
tick = not tick
|
|
192
|
-
elif not tick and ch in "()":
|
|
193
|
-
depth = depth + 1 if ch == "(" else max(0, depth - 1)
|
|
194
|
-
if ch == ";" and not tick and depth == 0:
|
|
195
|
-
parts.append(part)
|
|
196
|
-
part = ""
|
|
197
|
-
else:
|
|
198
|
-
part += ch
|
|
199
|
-
return [p.strip() for p in parts + [part] if p.strip()]
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
def references(cell: str) -> tuple[list[tuple[str, str | None]], list[str]]:
|
|
203
|
-
"""((name, id or None) per reference, the parts that are no reference) of a step table cell; `none` is empty."""
|
|
204
|
-
if cell.strip().lower() == "none":
|
|
205
|
-
return [], []
|
|
206
|
-
refs, prose = [], []
|
|
207
|
-
for part in split_references(cell):
|
|
208
|
-
m = REFERENCE.fullmatch(part)
|
|
209
|
-
if not m:
|
|
210
|
-
prose.append(part)
|
|
211
|
-
continue
|
|
212
|
-
ident = (m.group(2) or "").partition(",")[0].strip()
|
|
213
|
-
refs.append((m.group(1), ident or None))
|
|
214
|
-
return refs, prose
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
# --- checks shared by both levels ---------------------------------------------------------------
|
|
218
|
-
|
|
219
|
-
def check_common(text: str, level: str, sections: list[str], r: Report, min_criteria: int) -> None:
|
|
220
|
-
if not re.search(rf"UIPATH-AUTOMATION-GENOME:\s*{level}", text, re.I):
|
|
221
|
-
r.core(f"missing preamble comment 'UIPATH-AUTOMATION-GENOME: {level}'")
|
|
222
|
-
elif f"UIPATH-AUTOMATION-GENOME: {level}" not in text:
|
|
223
|
-
r.strict(f"preamble comment not written exactly 'UIPATH-AUTOMATION-GENOME: {level}'")
|
|
224
|
-
if not re.search(r"UiPath automation blueprint", text, re.I):
|
|
225
|
-
r.core("missing blueprint blockquote")
|
|
226
|
-
elif "This is a UiPath automation blueprint" not in text:
|
|
227
|
-
r.strict("blueprint blockquote not written as the template words it")
|
|
228
|
-
# format guide rule 5: the preamble routes the agent to uipath-genome, not to the Build With skills
|
|
229
|
-
comment = re.search(r"<!--\s*UIPATH-AUTOMATION-GENOME.*?-->", text, re.S | re.I)
|
|
230
|
-
if comment and "uipath-genome" not in comment.group(0):
|
|
231
|
-
r.strict("preamble comment does not name uipath-genome as the skill that builds the genome")
|
|
232
|
-
blockquote = re.search(r"^>.*UiPath automation blueprint.*$", text, re.M | re.I)
|
|
233
|
-
if blockquote and "uipath-genome" not in blockquote.group(0):
|
|
234
|
-
r.strict("blueprint blockquote does not name uipath-genome as the skill that builds the genome")
|
|
235
|
-
pos = h2_positions(text)
|
|
236
|
-
for s in sections:
|
|
237
|
-
if section_pos(pos, s) is None:
|
|
238
|
-
r.core(f"missing section '## {s}'")
|
|
239
|
-
elif s not in pos:
|
|
240
|
-
r.strict(f"section '## {s}' present under a longer or differently cased heading")
|
|
241
|
-
for name in RETIRED_SKILLS:
|
|
242
|
-
if name in text:
|
|
243
|
-
r.core(f"retired skill name '{name}' present")
|
|
244
|
-
# skill names are read where a genome names skills; elsewhere `uipath-…` is also an Integration
|
|
245
|
-
# Service connector key (`uipath-slack`, `uipath-salesforce-sfdc`), not a skill
|
|
246
|
-
for heading in ("Build With", "Components"):
|
|
247
|
-
for name in sorted(set(re.findall(r"`(uipath-[a-z-]+)`", section_body(text, heading)))):
|
|
248
|
-
if name not in VALID_SKILLS | OPERATE_SKILLS | {"uipath-genome"}:
|
|
249
|
-
r.core(f"unknown skill name '{name}' in {heading}")
|
|
250
|
-
for heading in ("Build With", "Components"):
|
|
251
|
-
for name in sorted(set(re.findall(r"`(uipath-[a-z-]+)`", section_body(text, heading)))):
|
|
252
|
-
if name in OPERATE_SKILLS:
|
|
253
|
-
# skill-mapping guide rule 2; advisory: a platform row in Build With does no harm — the
|
|
254
|
-
# resources still reach the target through the solution and the open-items files
|
|
255
|
-
r.strict(f"operate-only skill '{name}' in {heading}; it belongs under Platform Dependencies")
|
|
256
|
-
# a criterion is a list item in any form: '- ', '- [ ] ', '* ' or '1. '; the format guide numbers them
|
|
257
|
-
criteria = [l for l in section_body(text, "Acceptance Criteria").splitlines() if re.match(r"([-*]|\d+\.) \S", l)]
|
|
258
|
-
if len(criteria) < CORE_FLOOR:
|
|
259
|
-
r.core(f"acceptance criteria: {len(criteria)} found, expected >= {CORE_FLOOR}")
|
|
260
|
-
elif len(criteria) < min_criteria:
|
|
261
|
-
r.strict(f"acceptance criteria: {len(criteria)} found, expected >= {min_criteria} for the stated complexity")
|
|
262
|
-
if any(not re.match(r"\d+\. ", l) for l in criteria):
|
|
263
|
-
r.strict("acceptance criteria are not numbered ('1. …'), so a report cannot cite them by number")
|
|
264
|
-
for line in criteria:
|
|
265
|
-
if re.search(r"completes successfully|handles errors properly", line, re.I):
|
|
266
|
-
r.core(f"generic acceptance criterion: {line.strip()}")
|
|
267
|
-
|
|
268
|
-
body = body_without_source_map(text)
|
|
269
|
-
for tok in BANNED_BODY_TOKENS:
|
|
270
|
-
# a prefix token counts at the start of a word only: `in_Folder`, never "login_page" or "layout_name"
|
|
271
|
-
if (re.search(rf"\b{re.escape(tok)}\w", body) if tok.endswith("_") else tok in body):
|
|
272
|
-
r.strict(f"code-level token '{tok}' in the genome body (outside Source Map)")
|
|
273
|
-
for num, question in re.findall(r"^(\d+)\. (.*)$", section_body(text, "Configuration Questions"), re.M):
|
|
274
|
-
pointer = "?" not in question and re.search(r"Configuration Question \d+", question) # a question the process genome asks
|
|
275
|
-
if not pointer and not re.search(r"\((setting|constant); default:", question):
|
|
276
|
-
r.strict(f"configuration question {num} does not name its kind and default as '(setting; default: …)' or '(constant; default: …)'")
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
def effective_flows(ts: str) -> tuple[list[tuple[str, str]], bool]:
|
|
280
|
-
"""(flows, headed): the '### Flow N' blocks, or — when there is no such heading but the section names a
|
|
281
|
-
unit of work — the whole section as one flow. The heading is a format rule; the unit of work is the contract."""
|
|
282
|
-
blocks = flow_blocks(ts)
|
|
283
|
-
if blocks:
|
|
284
|
-
return blocks, True
|
|
285
|
-
if re.search(r"unit of work", ts, re.I):
|
|
286
|
-
return [("Flow 1", ts)], False
|
|
287
|
-
return [], False
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
@functools.cache
|
|
291
|
-
def template_placeholders() -> frozenset[str]:
|
|
292
|
-
"""The `{…}` placeholders of the templates' Transactional Shape sections, a one-word one with the word before it
|
|
293
|
-
(`with {result}`, `retried {n}`). A genome's own braces — a value built from parts, such as `{item}_{date}` or
|
|
294
|
-
`INV-{n}` — are content, not a placeholder left unfilled."""
|
|
295
|
-
found: set[str] = set()
|
|
296
|
-
for name in ("component-genome-template.md", "process-genome-template.md"):
|
|
297
|
-
path = TEMPLATES / name
|
|
298
|
-
if path.exists():
|
|
299
|
-
for m in re.finditer(rf"(\S+ )?({PLACEHOLDER.pattern})", section_body(path.read_text(encoding="utf-8"), "Transactional Shape")):
|
|
300
|
-
found.add((m.group(1) or "") + m.group(2) if ONE_WORD.fullmatch(m.group(2)) else m.group(2))
|
|
301
|
-
return frozenset(found)
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
def check_transactional(text: str, level: str, r: Report, part_of: bool = False) -> None:
|
|
305
|
-
"""Transactional Shape: the stub, or flow blocks the transactional shape guide describes."""
|
|
306
|
-
ts = section_body(text, "Transactional Shape")
|
|
307
|
-
if not ts.strip() or ts.strip().startswith(STUB):
|
|
308
|
-
return
|
|
309
|
-
if "**Recommendation:**" in ts or re.search(r"^\|\s*(Producer|Consumer)\s*\|", ts, re.M):
|
|
310
|
-
r.strict("Transactional Shape carries a verdict (Recommendation line or Producer/Consumer mode table)")
|
|
311
|
-
flows, headed = effective_flows(ts)
|
|
312
|
-
if not flows:
|
|
313
|
-
r.shape("Transactional Shape is neither the stub nor flows naming their unit of work")
|
|
314
|
-
return
|
|
315
|
-
if not headed:
|
|
316
|
-
r.strict("Transactional Shape describes its flow without '### Flow N' headings")
|
|
317
|
-
# a component reached through a process genome's links is inside it, with or without its 'Part of:' line
|
|
318
|
-
in_process = level == "component" and (part_of or "Part of:" in text)
|
|
319
|
-
if not in_process and "**Flows:**" not in ts:
|
|
320
|
-
r.strict("Transactional Shape has no 'Flows:' line")
|
|
321
|
-
template = template_placeholders() # without the templates beside the script, every lower-case `{…}` counts
|
|
322
|
-
unfilled = [p for p in template if p in ts] if template else PLACEHOLDER.findall(ts)
|
|
323
|
-
if unfilled:
|
|
324
|
-
r.strict(f"Transactional Shape leaves a template placeholder unfilled: {min(unfilled, key=ts.index)}")
|
|
325
|
-
for name, body in flows:
|
|
326
|
-
if in_process:
|
|
327
|
-
if "**Role:**" not in body:
|
|
328
|
-
r.shape(f"Transactional Shape {name}: a component inside a process has no 'Role:' line")
|
|
329
|
-
if "per the process genome" not in body:
|
|
330
|
-
r.strict(f"Transactional Shape {name}: does not point to the process genome's split options")
|
|
331
|
-
continue
|
|
332
|
-
if not re.search(r"unit of work", body, re.I):
|
|
333
|
-
r.shape(f"Transactional Shape {name}: names no unit of work")
|
|
334
|
-
elif "**Unit of work:**" not in body:
|
|
335
|
-
r.strict(f"Transactional Shape {name}: no '**Unit of work:**' line")
|
|
336
|
-
external = EXTERNAL_SIDE.search(body)
|
|
337
|
-
split = table_rows(body, "| Unit of work | Option |")
|
|
338
|
-
if not external and not split:
|
|
339
|
-
r.strict(f"Transactional Shape {name}: no Split options table and no 'outside this genome' line")
|
|
340
|
-
if "| Aspect | As-is |" not in body:
|
|
341
|
-
r.strict(f"Transactional Shape {name}: no As-is table")
|
|
342
|
-
consumer_outside = bool(external and external.group(1).lower() == "consumer")
|
|
343
|
-
if not consumer_outside:
|
|
344
|
-
rows = [row[0] for row in table_rows(body, "| Outcome |") if row]
|
|
345
|
-
for needed in ("Success", "Business exception", "System exception"):
|
|
346
|
-
if needed not in rows:
|
|
347
|
-
r.strict(f"Transactional Shape {name}: no '{needed}' outcome row")
|
|
348
|
-
for extra in [x for x in rows if x not in OUTCOME_ROWS]:
|
|
349
|
-
r.strict(f"Transactional Shape {name}: outcome row '{extra}' — a source's own results map to Success or a Business exception")
|
|
350
|
-
# the consumer owes the item retry and the consecutive-failure stop (transactional shape guide rule 4)
|
|
351
|
-
if not re.search(r"retr(y|ie)", body, re.I) or not re.search(r"consecutive|stops? after \d", body, re.I):
|
|
352
|
-
r.strict(f"Transactional Shape {name}: outcomes do not state the item retry and the consecutive-failure stop")
|
|
353
|
-
if external:
|
|
354
|
-
continue
|
|
355
|
-
units: dict[str, set[str]] = {}
|
|
356
|
-
for row in split:
|
|
357
|
-
m = re.match(r"([ABC])\b", row[1]) if len(row) >= 2 else None
|
|
358
|
-
if m:
|
|
359
|
-
units.setdefault(row[0], set()).add(m.group(1))
|
|
360
|
-
if len(row) >= 2 and row[1].strip() not in SPLIT_OPTIONS:
|
|
361
|
-
r.strict(f"Transactional Shape {name}: option cell '{row[1]}' of '{row[0]}' holds more than its letter — the transactional shape guide defines A, B and C")
|
|
362
|
-
for unit, opts in units.items():
|
|
363
|
-
if opts != SPLIT_OPTIONS:
|
|
364
|
-
r.strict(f"Transactional Shape {name}: unit '{unit}' lacks option(s) {sorted(SPLIT_OPTIONS - opts)}")
|
|
365
|
-
alt = next((l for l in body.splitlines() if l.startswith("**Alternative units of work:**")), "")
|
|
366
|
-
if alt and not re.search(r":\*\*\s*none\b", alt, re.I) and len(units) < 2:
|
|
367
|
-
r.strict(f"Transactional Shape {name}: alternative units of work named but split options cover only one unit")
|
|
368
|
-
header = next((l for l in body.splitlines() if l.strip().startswith("| Unit of work | Option |")), "")
|
|
369
|
-
cols = [c.lower() for c in cells(header)]
|
|
370
|
-
if "requires" not in cols or "changes against as-is" not in cols:
|
|
371
|
-
r.strict(f"Transactional Shape {name}: Split options table has no Requires and Changes against as-is columns")
|
|
372
|
-
continue
|
|
373
|
-
if cols != SPLIT_COLUMNS:
|
|
374
|
-
r.strict(f"Transactional Shape {name}: Split options columns are {cols}, expected Unit of work, Option, Requires, Changes against as-is")
|
|
375
|
-
ir, ic = cols.index("requires"), cols.index("changes against as-is")
|
|
376
|
-
for row in split:
|
|
377
|
-
if len(row) > max(ir, ic) and row[1][:1] in SPLIT_OPTIONS:
|
|
378
|
-
if not row[ir] or not row[ic]:
|
|
379
|
-
r.strict(f"Transactional Shape {name}: option {row[1][:1]} of '{row[0]}' has an empty Requires or Changes cell")
|
|
380
|
-
if re.search(r"\b(recommended|best option|preferred)\b", row[ir] + " " + row[ic], re.I):
|
|
381
|
-
r.strict(f"Transactional Shape {name}: option {row[1][:1]} of '{row[0]}' ranks the options")
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
def check_shape_assertion(text: str, shape: str, flows: int | None, units: list[str], r: Report) -> None:
|
|
385
|
-
"""--shape: what the Transactional Shape of this genome must describe."""
|
|
386
|
-
ts = section_body(text, "Transactional Shape")
|
|
387
|
-
stub = ts.strip().startswith(STUB)
|
|
388
|
-
if shape == "stub":
|
|
389
|
-
if not stub:
|
|
390
|
-
r.core("Transactional Shape: expected the 'Not transactional' stub")
|
|
391
|
-
return
|
|
392
|
-
if stub:
|
|
393
|
-
r.core("Transactional Shape: expected flow blocks, found the stub")
|
|
394
|
-
return
|
|
395
|
-
blocks, _ = effective_flows(ts)
|
|
396
|
-
if not blocks:
|
|
397
|
-
r.core("Transactional Shape: expected flows naming their unit of work, found none")
|
|
398
|
-
return
|
|
399
|
-
if flows is not None and len(blocks) != flows:
|
|
400
|
-
r.core(f"Transactional Shape: {len(blocks)} flow(s), expected {flows}")
|
|
401
|
-
# the primary unit's line only: never the alternatives line or a table header, and whole words ('row', not 'throw')
|
|
402
|
-
unit_lines = " ".join(l for l in ts.splitlines() if re.match(r"[*_\s>-]*unit of work\b", l, re.I))
|
|
403
|
-
for tok in units:
|
|
404
|
-
if not re.search(rf"\b{re.escape(tok)}s?\b", unit_lines, re.I):
|
|
405
|
-
r.core(f"Transactional Shape: no 'Unit of work' line names '{tok}'")
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
def check_steps_table(text: str, r: Report) -> None:
|
|
409
|
-
"""An extracted genome's step table: one row per Workflow step (core), reference-only cells (strict)."""
|
|
410
|
-
if not section_body(text, "Source Map").strip():
|
|
411
|
-
return
|
|
412
|
-
table = steps_table(text)
|
|
413
|
-
if table is None:
|
|
414
|
-
r.core("Source Map has no '### Steps' table pairing each Workflow step with its source objects")
|
|
415
|
-
return
|
|
416
|
-
header, rows = table
|
|
417
|
-
if header != STEPS_COLUMNS:
|
|
418
|
-
r.strict(f"step table columns are {header}, expected Step, Source objects, Data sets, Captures, Notes")
|
|
419
|
-
steps = workflow_steps(text)
|
|
420
|
-
keys = [row[0] for row in rows]
|
|
421
|
-
for step in steps:
|
|
422
|
-
if keys.count(step) != 1:
|
|
423
|
-
r.core(f"step table: Workflow step {step} has {keys.count(step)} rows, expected exactly one")
|
|
424
|
-
for key in sorted(set(keys) - set(steps), key=lambda k: (len(k), k)):
|
|
425
|
-
r.core(f"step table: row '{key}' names no Workflow step — key a row by the step's number only")
|
|
426
|
-
for row in rows:
|
|
427
|
-
row = row + [""] * (len(STEPS_COLUMNS) - len(row))
|
|
428
|
-
sources, prose = references(row[1])
|
|
429
|
-
if not sources:
|
|
430
|
-
r.strict(f"step table, step {row[0]}: no source object")
|
|
431
|
-
data, data_prose = references(row[2])
|
|
432
|
-
for part in prose + data_prose:
|
|
433
|
-
r.strict(f"step table, step {row[0]}: '{part[:60]}' is not a reference — move it to Notes")
|
|
434
|
-
if not data and row[2].strip().lower() != "none":
|
|
435
|
-
r.strict(f"step table, step {row[0]}: Data sets is empty — write 'none' when the step reads no data set")
|
|
436
|
-
if not re.fullmatch(r"\d+", row[3]):
|
|
437
|
-
r.strict(f"step table, step {row[0]}: Captures '{row[3]}' is not a count")
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
# --- levels -------------------------------------------------------------------------------------
|
|
441
|
-
|
|
442
|
-
def component_links(path: Path, text: str) -> list[tuple[str, Path, bool]]:
|
|
443
|
-
"""(link, component genome path, is a library) per row of a process genome's Components table."""
|
|
444
|
-
out = []
|
|
445
|
-
for row in table_rows(section_body(text, "Components"), "| #"):
|
|
446
|
-
m = re.search(r"\]\(([^)]+-genome\.md)\)", " | ".join(row))
|
|
447
|
-
if m:
|
|
448
|
-
out.append((m.group(1), (path.parent / m.group(1)).resolve(),
|
|
449
|
-
len(row) > 2 and bool(re.search(r"\blibrary\b", row[2], re.I))))
|
|
450
|
-
return out
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
def check_component(path: Path, a: argparse.Namespace, part_of: bool, shape: bool = True, library: bool = False) -> list[str]:
|
|
454
|
-
text = path.read_text(encoding="utf-8")
|
|
455
|
-
# a library is named so in its process genome's Components table, or in its own Transactional Shape stub
|
|
456
|
-
library = library or bool(re.search(r"^Not transactional:[^\n]*\blibrar(y|ies)\b", section_body(text, "Transactional Shape").strip(), re.I))
|
|
457
|
-
r = Report(a.profile, a.shape_checks == "gate")
|
|
458
|
-
level = complexity_of(text)
|
|
459
|
-
min_steps = MIN_STEPS_BY_COMPLEXITY.get(level, a.min_steps)
|
|
460
|
-
check_common(text, "component", COMPONENT_SECTIONS, r, MIN_CRITERIA_BY_COMPLEXITY.get(level, a.min_criteria))
|
|
461
|
-
pos = h2_positions(text)
|
|
462
|
-
bw, wf = section_pos(pos, "Build With"), section_pos(pos, "Workflow")
|
|
463
|
-
if bw is not None and wf is not None and bw > wf:
|
|
464
|
-
r.core("Build With must precede Workflow")
|
|
465
|
-
if not re.search(r"uipath-[a-z-]+", section_body(text, "Build With")):
|
|
466
|
-
r.core("Build With names no skill")
|
|
467
|
-
workflow = section_body(text, "Workflow")
|
|
468
|
-
steps = len(re.findall(r"^(?:\d+\.|[-*]) \S", workflow, re.M)) # top-level numbered or bulleted steps
|
|
469
|
-
# a test component's steps are its cases and a library's its public workflows (format guide § Population Matrix)
|
|
470
|
-
exempt = library or bool(re.search(r"^\d+\. \*\*Test case:", workflow, re.M))
|
|
471
|
-
if steps < CORE_FLOOR and not exempt:
|
|
472
|
-
r.core(f"workflow: {steps} numbered steps, expected >= {CORE_FLOOR}")
|
|
473
|
-
elif steps < min_steps and not exempt:
|
|
474
|
-
r.strict(f"workflow: {steps} numbered steps, expected >= {min_steps} for complexity {level or 'not stated'}")
|
|
475
|
-
if len(re.findall(r"^\d+\. \*\*", workflow, re.M)) < min(steps, min_steps):
|
|
476
|
-
r.strict("workflow: steps not all in the '1. **Step name**' form")
|
|
477
|
-
cq = section_body(text, "Configuration Questions")
|
|
478
|
-
questions = re.findall(r"^\d+\. ", cq, re.M)
|
|
479
|
-
if not cq.strip():
|
|
480
|
-
r.core("Configuration Questions section is empty")
|
|
481
|
-
elif not questions and "no configuration needed" not in cq:
|
|
482
|
-
r.strict("Configuration Questions: neither a numbered list of questions nor the stub line")
|
|
483
|
-
if a.source_map:
|
|
484
|
-
sm = section_body(text, "Source Map")
|
|
485
|
-
if not sm.strip():
|
|
486
|
-
r.core("missing or empty '## Source Map' section")
|
|
487
|
-
for tok in a.source_map:
|
|
488
|
-
if tok not in sm:
|
|
489
|
-
r.core(f"Source Map does not mention '{tok}'")
|
|
490
|
-
check_steps_table(text, r)
|
|
491
|
-
if part_of and "Part of:" not in text:
|
|
492
|
-
r.strict("component inside a process genome lacks the 'Part of:' line")
|
|
493
|
-
check_transactional(text, "component", r, part_of)
|
|
494
|
-
if a.shape and shape:
|
|
495
|
-
check_shape_assertion(text, a.shape, a.flows, a.unit, r)
|
|
496
|
-
for tok in a.expect:
|
|
497
|
-
if tok.lower() not in text.lower():
|
|
498
|
-
r.core(f"expected token '{tok}' not found")
|
|
499
|
-
return [f"{path.name}: {e}" for e in r.errors]
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
def check_process(path: Path, a: argparse.Namespace) -> list[str]:
|
|
503
|
-
text = path.read_text(encoding="utf-8")
|
|
504
|
-
r = Report(a.profile, a.shape_checks == "gate")
|
|
505
|
-
check_common(text, "process", PROCESS_SECTIONS, r, MIN_CRITERIA_BY_COMPLEXITY.get(complexity_of(text), a.min_criteria))
|
|
506
|
-
pos = h2_positions(text)
|
|
507
|
-
cp, pm = section_pos(pos, "Components"), section_pos(pos, "Process Map")
|
|
508
|
-
if cp is not None and pm is not None and cp > pm:
|
|
509
|
-
r.core("Components must precede Process Map")
|
|
510
|
-
comp = section_body(text, "Components")
|
|
511
|
-
if len([l for l in comp.splitlines() if l.startswith("|") and "uipath-" in l]) < 2:
|
|
512
|
-
r.core("Components table: fewer than 2 rows naming a skill")
|
|
513
|
-
for s in a.skills:
|
|
514
|
-
if not re.search(rf"\b{re.escape(s)}\b", comp):
|
|
515
|
-
r.core(f"Components table lacks skill '{s}'")
|
|
516
|
-
for row in table_rows(comp, "| #"):
|
|
517
|
-
if len(row) > 2 and re.search(r"\b(dispatcher|performer)\b", row[2], re.I):
|
|
518
|
-
r.strict(f"Components: role word in the Type cell of '{row[1]}' — it reads the component type only")
|
|
519
|
-
links = component_links(path, text)
|
|
520
|
-
if not links:
|
|
521
|
-
r.core("Components table links no component genome")
|
|
522
|
-
component_errors: list[str] = []
|
|
523
|
-
for link, target, is_library in links:
|
|
524
|
-
if not target.exists():
|
|
525
|
-
r.core(f"linked component genome missing on disk: {link}")
|
|
526
|
-
else:
|
|
527
|
-
component_errors.extend(check_component(target, argparse.Namespace(**{**vars(a), "expect": [], "source_map": []}),
|
|
528
|
-
part_of=True, shape=False, library=is_library))
|
|
529
|
-
handoffs = [l for l in section_body(text, "Handoffs").splitlines() if l.startswith("|")]
|
|
530
|
-
if len(handoffs) < 4: # header + separator + >= 2 rows
|
|
531
|
-
r.core(f"Handoffs table: {max(0, len(handoffs) - 2)} rows, expected >= 2")
|
|
532
|
-
check_transactional(text, "process", r)
|
|
533
|
-
if a.shape:
|
|
534
|
-
check_shape_assertion(text, a.shape, a.flows, a.unit, r)
|
|
535
|
-
for tok in a.expect:
|
|
536
|
-
if tok.lower() not in text.lower():
|
|
537
|
-
r.core(f"expected token '{tok}' not found")
|
|
538
|
-
return [f"{path.name}: {e}" for e in r.errors] + component_errors
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
def check_export(genomes: list[tuple[Path, bool]], processes: list[dict], recordsets: list[dict]) -> tuple[list[str], list[str]]:
|
|
542
|
-
"""(failures, notes) of every step table against the export's inventory. Ids are compared as text."""
|
|
543
|
-
by_id = {str(p["id"]): p for p in processes}
|
|
544
|
-
by_name: dict[str, list[dict]] = {}
|
|
545
|
-
for p in processes:
|
|
546
|
-
by_name.setdefault(p["name"].lower(), []).append(p)
|
|
547
|
-
data = {str(d["id"]): d for d in recordsets}
|
|
548
|
-
errors, notes, used = [], [], []
|
|
549
|
-
for path, is_library in genomes:
|
|
550
|
-
table = steps_table(path.read_text(encoding="utf-8")) if path.exists() else None
|
|
551
|
-
for row in (table[1] if table else []):
|
|
552
|
-
row = row + [""] * (len(STEPS_COLUMNS) - len(row))
|
|
553
|
-
where = f"{path.name} step {row[0]}"
|
|
554
|
-
sources, _ = references(row[1])
|
|
555
|
-
if not sources:
|
|
556
|
-
errors.append(f"{where}: no source object")
|
|
557
|
-
for name, ident in sources:
|
|
558
|
-
p = by_id.get(ident or "")
|
|
559
|
-
if ident is None:
|
|
560
|
-
errors.append(f"{where}: `{name}` has no id — cite it as `Name` (id)")
|
|
561
|
-
elif p is None:
|
|
562
|
-
hint = " — it is a data set: move it to Data sets" if ident in data else ""
|
|
563
|
-
errors.append(f"{where}: `{name}` ({ident}) is no process of the export{hint}")
|
|
564
|
-
elif p["name"].lower() != name.lower():
|
|
565
|
-
errors.append(f"{where}: id {ident} is `{p['name']}`, the row says `{name}`")
|
|
566
|
-
else:
|
|
567
|
-
used.append((where, is_library, p))
|
|
568
|
-
for name, ident in references(row[2])[0]:
|
|
569
|
-
d = data.get(ident or "")
|
|
570
|
-
if ident is None:
|
|
571
|
-
errors.append(f"{where}: data set `{name}` has no id — cite it as `Name` (id)")
|
|
572
|
-
elif d is None:
|
|
573
|
-
hint = " — it is a process: move it to Source objects" if ident in by_id else ""
|
|
574
|
-
errors.append(f"{where}: data set `{name}` ({ident}) is no data set of the export{hint}")
|
|
575
|
-
elif d.get("drives", True) is False:
|
|
576
|
-
errors.append(f"{where}: `{name}` ({ident}) drives nothing (a file the step writes, a URL) — name it in Notes")
|
|
577
|
-
elif d["name"].lower() != name.lower() and not d["name"].lower().endswith("::" + name.lower()):
|
|
578
|
-
errors.append(f"{where}: data set id {ident} is `{d['name']}`, the row says `{name}`")
|
|
579
|
-
# the built roots: every process a non-library step was built from, and what they call
|
|
580
|
-
scope = {str(p["id"]) for _, lib, p in used if not lib} or set(by_id)
|
|
581
|
-
frontier = list(scope)
|
|
582
|
-
while frontier:
|
|
583
|
-
for c in (by_id.get(frontier.pop()) or {}).get("calls", []):
|
|
584
|
-
callee = str(c.get("calleeId"))
|
|
585
|
-
if callee not in scope:
|
|
586
|
-
scope.add(callee)
|
|
587
|
-
frontier.append(callee)
|
|
588
|
-
for where, lib, p in used:
|
|
589
|
-
if lib and str(p["id"]) not in scope:
|
|
590
|
-
twins = [str(q["id"]) for q in by_name.get(p["name"].lower(), []) if str(q["id"]) in scope]
|
|
591
|
-
if twins:
|
|
592
|
-
errors.append(f"{where}: `{p['name']}` ({p['id']}) is not reachable from the built roots; the copy they run is {', '.join(twins)}")
|
|
593
|
-
else:
|
|
594
|
-
notes.append(f"{where}: `{p['name']}` ({p['id']}) is a library workflow no built component calls")
|
|
595
|
-
return errors, notes
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
def resolve(pattern: str) -> list[Path]:
|
|
599
|
-
path = Path(pattern)
|
|
600
|
-
if path.exists() or not any(c in pattern for c in "*?["):
|
|
601
|
-
return [path] if path.exists() else []
|
|
602
|
-
return sorted(Path(".").glob(pattern))
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
def check_tokens(paths: list[Path], tokens: list[str], minimum: float, files: int | None) -> list[str]:
|
|
606
|
-
errors: list[str] = []
|
|
607
|
-
if files is not None and len(paths) != files:
|
|
608
|
-
errors.append(f"{len(paths)} file(s) match, expected {files}: {', '.join(p.as_posix() for p in paths) or 'none'}")
|
|
609
|
-
text = "\n".join(p.read_text(encoding="utf-8") for p in paths)
|
|
610
|
-
missing = [t for t in tokens if t not in text]
|
|
611
|
-
if tokens and (len(tokens) - len(missing)) / len(tokens) < minimum:
|
|
612
|
-
errors.append(f"{len(tokens) - len(missing)}/{len(tokens)} tokens found, expected >= {minimum:.0%}; missing: {', '.join(missing)}")
|
|
613
|
-
return errors
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
def load_inventory(path: str, what: str) -> list[dict]:
|
|
617
|
-
data = json.loads(Path(path).read_text(encoding="utf-8"))
|
|
618
|
-
if not isinstance(data, list) or not all(isinstance(x, dict) and "id" in x and "name" in x for x in data):
|
|
619
|
-
sys.exit(f"FAIL: {path}: the {what} is a list of objects with 'id' and 'name' (regenerate it with the source guide's script)")
|
|
620
|
-
return data
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
def main(argv: list[str] | None = None) -> int:
|
|
624
|
-
ap = argparse.ArgumentParser()
|
|
625
|
-
ap.add_argument("level", choices=["component", "process", "tokens"])
|
|
626
|
-
ap.add_argument("genome")
|
|
627
|
-
ap.add_argument("--profile", choices=["core", "strict"], default="core")
|
|
628
|
-
ap.add_argument("--expect", nargs="*", default=[])
|
|
629
|
-
ap.add_argument("--source-map", nargs="*", default=[])
|
|
630
|
-
ap.add_argument("--skills", nargs="*", default=[])
|
|
631
|
-
ap.add_argument("--shape", choices=["transactional", "stub"], default=None)
|
|
632
|
-
ap.add_argument("--shape-checks", choices=["gate", "advisory"], default="gate")
|
|
633
|
-
ap.add_argument("--flows", type=int, default=None)
|
|
634
|
-
ap.add_argument("--unit", nargs="*", default=[])
|
|
635
|
-
ap.add_argument("--min-steps", type=int, default=5, help="format guide: 3 simple, 5 medium, 8 complex")
|
|
636
|
-
ap.add_argument("--min-criteria", type=int, default=5, help="format guide: 3 simple, 5 medium, 7 complex")
|
|
637
|
-
ap.add_argument("--min", type=float, default=1.0, help="tokens: fraction of --expect tokens that must be found")
|
|
638
|
-
ap.add_argument("--files", type=int, default=None, help="tokens: exact number of files the pattern must match")
|
|
639
|
-
ap.add_argument("--processes", help="process inventory JSON the framework script derived from the export")
|
|
640
|
-
ap.add_argument("--recordsets", help="recordset list JSON from the same script")
|
|
641
|
-
a = ap.parse_args(argv)
|
|
642
|
-
if bool(a.processes) != bool(a.recordsets):
|
|
643
|
-
ap.error("--processes and --recordsets go together")
|
|
644
|
-
|
|
645
|
-
paths = resolve(a.genome)
|
|
646
|
-
notes: list[str] = []
|
|
647
|
-
if a.level == "tokens":
|
|
648
|
-
errors = ([f"no file matches {a.genome}"] if not paths else []) + check_tokens(paths, a.expect, a.min, a.files)
|
|
649
|
-
elif len(paths) != 1:
|
|
650
|
-
errors = [f"expected exactly one file matching {a.genome}, found {len(paths)}: {', '.join(p.as_posix() for p in paths) or 'none'}"]
|
|
651
|
-
else:
|
|
652
|
-
errors = (check_component(paths[0], a, part_of=False) if a.level == "component" else check_process(paths[0], a))
|
|
653
|
-
if a.processes:
|
|
654
|
-
text = paths[0].read_text(encoding="utf-8")
|
|
655
|
-
genomes = ([(target, lib) for _, target, lib in component_links(paths[0], text)]
|
|
656
|
-
if a.level == "process" else [(paths[0], False)])
|
|
657
|
-
export_errors, notes = check_export(genomes, load_inventory(a.processes, "process inventory"),
|
|
658
|
-
load_inventory(a.recordsets, "recordset list"))
|
|
659
|
-
errors += export_errors
|
|
660
|
-
for e in errors:
|
|
661
|
-
print(f"FAIL: {e}")
|
|
662
|
-
for n in notes:
|
|
663
|
-
print(f"NOTE: {n}")
|
|
664
|
-
if not errors:
|
|
665
|
-
print(f"OK ({a.profile if a.level != 'tokens' else 'tokens'}): {', '.join(p.as_posix() for p in paths)}")
|
|
666
|
-
return 1 if errors else 0
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
if __name__ == "__main__":
|
|
670
|
-
sys.exit(main())
|