From 78ff098a5ea159c19d71408faac3b46343419a04 Mon Sep 17 00:00:00 2001 From: Dan Wolfson Date: Wed, 11 Nov 2026 21:45:50 +0000 Subject: [PATCH 1/4] fix(dr-egeria): a bullet in a list attribute is one item, commas and all (6.2.39) Dr.Egeria split every list attribute value (Simple List, List, NameList, Reference Name List) on commas, semicolons and newlines, in both the v2 parser (md_processing/v2/parsing.py) and the older path (common_md_proc_utils: Simple List in both attribute parsers, and reference name lists). A bullet with a comma became two items: the CDO workbook metric "Recovery Test Coverage" (it-governance-program.md:636-639) is stored in Egeria with 6 implications instead of 4, and line 53's "... depending domain, not set by IT alone" splits the same way. - New common_md_utils.split_list_value(): a bulleted or multi-line value is one item per bullet/line, verbatim (bullet marker stripped); a single line is split on commas and semicolons, including an inline bulleted list ("- a; - b, c"); a lone bullet line is one item. Spec metadata (labels, valid values) keeps split_tb_string. - Tests: the two real workbook commands (copied verbatim) give 4 implications each with the commas kept; single-line "a, b" gives 2; one bullet with a comma gives 1; the laz capture shows the 6-item value stored today. The two workbook tests fail on 70da8d51. - Update replaces, not appends: Dr.Egeria sends the whole list with mergeUpdate true, and Egeria's merge update sets each supplied property whole (OpenMetadataAPIGenericHandler.setUpNewProperties, OMRSRepositoryContentHelper.mergeInstanceProperties), so re-running the documents corrects the data. Release notes: docs/release-notes/6.2.39.md. Signed-off-by: Dan Wolfson --- docs/release-notes/6.2.39.md | 21 +++++ .../common_md_proc_utils.py | 7 +- .../md_processing_utils/common_md_utils.py | 34 +++++++ md_processing/v2/parsing.py | 14 +-- .../it_governance_program_excerpt.md | 89 +++++++++++++++++++ .../test_list_attribute_bullets.py | 79 ++++++++++++++++ 6 files changed, 231 insertions(+), 13 deletions(-) create mode 100644 docs/release-notes/6.2.39.md create mode 100644 tests/micro-tests/data/dr_egeria/it_governance_program_excerpt.md create mode 100644 tests/micro-tests/test_list_attribute_bullets.py diff --git a/docs/release-notes/6.2.39.md b/docs/release-notes/6.2.39.md new file mode 100644 index 00000000..8720aa78 --- /dev/null +++ b/docs/release-notes/6.2.39.md @@ -0,0 +1,21 @@ +# pyegeria 6.2.39 + +pyegeria 6.2.39 fixes how Dr.Egeria reads list attributes. + +## Fixed + +- **A bullet containing a comma was split into two items.** Dr.Egeria split every list attribute's value (`Simple + List`, `List`, `NameList`, `Reference Name List`, in both the v2 parser and the older md_processing path) on + commas, semicolons and newlines. A bullet such as "Results go to the Service Owner and the depending domain, not + only to IT" became two items. The CDO workbook's IT governance metric "Recovery Test Coverage" was stored with 6 + implications instead of 4. + - Now a bulleted or multi-line value is one item per bullet (or line), verbatim, with the leading `- `, `* ` or + `+ ` removed. + - A single-line value is still split on commas and semicolons ("a, b" is two items), including an inline + bulleted list on one line ("- a; - b, c" is three). + - **Behaviour change:** a single bullet on its own line, such as "- a, b", is now one item (it used to be two). + - Spec metadata (labels, valid values) is parsed as before. + +**Correcting stored data:** re-run the affected Dr.Egeria documents. An Update (or a Create that becomes an Update) +sends the whole list with `mergeUpdate: true`, and Egeria's merge update replaces a property's value as a whole, so +the list is replaced, not appended. A list attribute left out of the document is not changed. diff --git a/md_processing/md_processing_utils/common_md_proc_utils.py b/md_processing/md_processing_utils/common_md_proc_utils.py index e585beda..e245a7c8 100644 --- a/md_processing/md_processing_utils/common_md_proc_utils.py +++ b/md_processing/md_processing_utils/common_md_proc_utils.py @@ -18,6 +18,7 @@ from md_processing.md_processing_utils.common_md_utils import ( get_current_datetime_string, split_tb_string, + split_list_value, str_to_bool, normalize_value, print_msg, @@ -422,7 +423,7 @@ def parse_upsert_command(egeria_client: EgeriaTech, object_type: str, object_act ) name_list = parsed_attributes[key]['value'] # attribute = re.split(r'[;,\n]+', name_list) if name_list is not None else None - attribute = split_tb_string(name_list) + attribute = split_list_value(name_list) # 6.2.39: a bullet is one item parsed_attributes[key]['value'] = attribute parsed_attributes[key]['name_list'] = name_list elif style == 'Parent': @@ -729,7 +730,7 @@ def _to_snake_case(name: str) -> str: ) name_list = parsed_attributes[key]['value'] # attribute = re.split(r'[;,\n]+', name_list) if name_list is not None else None - attribute = split_tb_string(name_list) + attribute = split_list_value(name_list) # 6.2.39: a bullet is one item parsed_attributes[key]['value'] = attribute parsed_attributes[key]['name_list'] = name_list elif style == 'Parent': @@ -1342,7 +1343,7 @@ def proc_name_list(egeria_client: EgeriaTech, element_type: str, txt: str, eleme return {"status": if_missing, "reason": msg, "value": None, "valid": False, "exists": False, } else: # element_list = re.split(r'[;,\n]+', elements_txt) - element_list = split_tb_string(elements_txt) + element_list = split_list_value(elements_txt) # 6.2.39: a bullet is one name element_details = {} for element in element_list: # Get the element using the generalized function diff --git a/md_processing/md_processing_utils/common_md_utils.py b/md_processing/md_processing_utils/common_md_utils.py index 7621270d..44eb5f99 100644 --- a/md_processing/md_processing_utils/common_md_utils.py +++ b/md_processing/md_processing_utils/common_md_utils.py @@ -76,6 +76,40 @@ def split_tb_string(input: str)-> [Any]: results.append(item) return results +_LIST_BULLET = re.compile(r'^\s*[\-\*\+]\s+') +#: A separator followed by another bullet marker: an inline list on one line ("- a; - b, c"). +_INLINE_BULLETS = re.compile(r'[;,]\s*[\-\*\+]\s+') + + +def split_list_value(text: Any) -> list | None: + """The items of a list attribute's VALUE (Simple List, List, NameList, Reference Name List). + + - A bulleted or multi-line value: each bullet (or line) is one item, verbatim -- a comma inside a + bullet is part of the item ("- agreed with the depending domain, not set by IT alone" is one + item). A leading markdown bullet (`- `, `* `, `+ `) is stripped. + - A single-line value is split on commas and semicolons ("a, b" is two items), including an inline + bulleted list on one line ("- a; - b, c" is three); a single bullet on its own line is one item. + + Until 6.2.39 every value was split on commas, semicolons and newlines, so a bullet with a comma + became two items. Spec metadata (labels, valid values) still uses `split_tb_string`. + """ + if text is None: + return None + if isinstance(text, (list, tuple)): + return [str(i).strip() for i in text if str(i).strip()] + lines = [line for line in str(text).splitlines() if line.strip()] + if not lines: + return [] + if len(lines) > 1: + items = [_LIST_BULLET.sub('', line).strip() for line in lines] + return [item for item in items if item] + line = lines[0] + if _LIST_BULLET.match(line) and not _INLINE_BULLETS.search(line): + return [_LIST_BULLET.sub('', line).strip()] # one bullet: one item, commas and all + items = [_LIST_BULLET.sub('', item).strip() for item in re.split(r'[;,]+', line)] + return [item for item in items if item] + + def str_to_bool(value: str) -> bool: """Converts a string to a boolean value.""" return value.lower() in ("yes", "true", "t", "1") diff --git a/md_processing/v2/parsing.py b/md_processing/v2/parsing.py index e1e0ab3f..74ea8970 100644 --- a/md_processing/v2/parsing.py +++ b/md_processing/v2/parsing.py @@ -11,7 +11,7 @@ import pyegeria.core._globals as pyeg_globals from md_processing.md_processing_utils.md_processing_constants import get_command_spec, load_commands import md_processing.md_processing_utils.md_processing_constants as md_constants -from md_processing.md_processing_utils.common_md_utils import normalize_value +from md_processing.md_processing_utils.common_md_utils import normalize_value, split_list_value from .extraction import DrECommand from .utils import parse_key_value, parse_line_list, parse_table @@ -416,15 +416,9 @@ async def _process_attribute_value(self, value: str, details: dict) -> Any: return v elif style in {"List", "NameList", "Simple List", "Reference Name List"}: - items = re.split(r'[;,\n]+', value) - results = [] - for item in items: - item = item.strip() - if item: - # Strip leading markdown bullet if present - item = re.sub(r'^[\-\*\+]\s*', '', item) - results.append(item) - return results + # 6.2.39: a bulleted or multi-line value is one item per bullet, verbatim (a comma inside a + # bullet stays in it); only a single-line value is split on commas and semicolons. + return split_list_value(value) return value diff --git a/tests/micro-tests/data/dr_egeria/it_governance_program_excerpt.md b/tests/micro-tests/data/dr_egeria/it_governance_program_excerpt.md new file mode 100644 index 00000000..67e4053d --- /dev/null +++ b/tests/micro-tests/data/dr_egeria/it_governance_program_excerpt.md @@ -0,0 +1,89 @@ + + +## Create Business Imperative + +### Display Name +Digital Services the Business Can Depend On + +### Qualified Name +CocoPharma::BusinessImperative::DependableDigitalServices + +### Domain Identifier +IT Infrastructure + +### Summary +Coco Pharmaceuticals must run digital services whose availability, change behaviour, and recovery characteristics are known and agreed, so that the domains depending on them can make commitments of their own. + +### Description +Every regulatory commitment the company makes is, somewhere underneath, a commitment about a system. A batch cannot be released if the electronic batch record system is unavailable; a data subject request cannot be answered in a month if the systems holding the data cannot be searched; expedited safety reporting cannot meet a seven-day deadline through a manual workaround. What the business needs from this domain is not maximal availability everywhere, which is unaffordable, but *known* characteristics — an agreed service level, an understood recovery time, and a change process that does not surprise the people who depend on the service. This imperative is deliberately expressed as dependability rather than uptime, because a service that is reliably available four days a week is more useful to plan around than one that is usually available and occasionally not. The measure of success is that other domains can state their own commitments with confidence, not that this domain reports high availability figures. + +### Implications +- Service characteristics must be agreed with the depending domain, not set by IT alone +- Recovery objectives must reflect what the business actually needs, which differs sharply by service +- Change behaviour must be predictable, since unpredictability is itself an availability problem +- Investment must be justified by the obligations it lets other domains discharge + +### Outcomes +- Domains can make regulatory and business commitments knowing what they rest on +- Service investment is directed by consequence rather than by uniform standards +- Unplanned change ceases to be a source of compliance failure in other domains + +### Importance +High + +### Category +IT Infrastructure + +### Authors +Gary Geeke + +### Version Identifier +1.0 + +### Content Status +ACTIVE + +___ + + +--- + +## Create Governance Metric + +### Display Name +Recovery Objective Test Coverage and Achievement + +### Qualified Name +CocoPharma::GovernanceMetric::RecoveryTestCoverage + +### Domain Identifier +IT Infrastructure + +### Summary +Measures the percentage of services with a recovery objective that have been exercised within their test cycle, and the proportion of those exercises that met the agreed objective. + +### Description +Coverage and achievement are separate questions and both matter. Coverage asks whether the exercise happened; achievement asks whether the tested recovery met what the depending domain was promised. A service with high coverage and poor achievement is honestly reported and correctable; one with poor coverage is a service whose stated objective is unverified, and unverified objectives are the ones that fail during an actual incident. Reporting is per service and goes to the Service Owner and the depending domain rather than only to the infrastructure team, which is the arrangement that makes a shortfall actionable by the people it affects. Services supporting regulatory deadlines — batch release, safety reporting, data subject requests — are reported separately because a recovery shortfall there converts directly into a missed statutory obligation. Where achievement falls persistently short and the gap cannot be closed economically, the metric is the evidence for renegotiating the objective rather than continuing to report failure against a target nobody can meet. + +### Implications +- Coverage and achievement are distinct measures and both are required +- Results go to the Service Owner and the depending domain, not only to IT +- Services supporting regulatory deadlines are reported separately +- Persistent shortfall is evidence for renegotiating the objective, not for repeated failure reporting + +### Outcomes +- Stated recovery objectives are verified rather than assumed +- Depending domains learn of shortfalls before an incident reveals them +- Objectives converge on what can actually be delivered + +### Authors +Gary Geeke + +### Version Identifier +1.0 + +### Content Status +ACTIVE + +___ + diff --git a/tests/micro-tests/test_list_attribute_bullets.py b/tests/micro-tests/test_list_attribute_bullets.py new file mode 100644 index 00000000..98dd9ce3 --- /dev/null +++ b/tests/micro-tests/test_list_attribute_bullets.py @@ -0,0 +1,79 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright Contributors to the ODPi Egeria project. +"""6.2.39: a bulleted list attribute keeps one item per bullet; a comma inside a bullet stays in it. + +Dr.Egeria used to split every list value on commas, semicolons and newlines, so the CDO workbook's +"Recovery Objective Coverage and Achievement" metric (4 bullets, two with commas) was stored in Egeria +with 6 implications (see the governance_metrics capture). The commands below are copied verbatim from +egeria-workspaces coco-workbooks/4. keeping-safe/it-governance-program.md.""" +import asyncio +import gzip +import json +from pathlib import Path + +import pytest + +from md_processing.md_processing_utils.common_md_proc_utils import split_list_value +from md_processing.md_processing_utils.common_md_utils import split_tb_string +from md_processing.md_processing_utils.md_processing_constants import load_commands +from md_processing.v2.parsing import parse_dr_egeria_content + +pytestmark = pytest.mark.unit + +DATA = Path(__file__).parent / "data" +EXCERPT = (DATA / "dr_egeria" / "it_governance_program_excerpt.md").read_text() + +METRIC_IMPLICATIONS = [ + "Coverage and achievement are distinct measures and both are required", + "Results go to the Service Owner and the depending domain, not only to IT", + "Services supporting regulatory deadlines are reported separately", + "Persistent shortfall is evidence for renegotiating the objective, not for repeated failure reporting", +] +IMPERATIVE_FIRST = "Service characteristics must be agreed with the depending domain, not set by IT alone" + + +def _parsed(): + load_commands() + return asyncio.run(parse_dr_egeria_content(EXCERPT)) + + +def test_the_workbook_metric_has_four_implications(): + metric = next(c for c in _parsed() if c["object_type"] == "Governance Metric") + assert metric["attributes"]["Implications"]["value"] == METRIC_IMPLICATIONS + + +def test_the_workbook_imperative_keeps_its_comma(): + imperative = next(c for c in _parsed() if c["object_type"] == "Business Imperative") + implications = imperative["attributes"]["Implications"]["value"] + assert implications[0] == IMPERATIVE_FIRST and len(implications) == 4 + + +def test_egeria_holds_the_split_value_today(): + """The bug as captured read-only on laz (2026-11-11): the same metric stored with 6 implications.""" + capture = json.loads(gzip.open(DATA / "report_specs" / "governance_metrics.json.gz").read()) + stored = next(e["properties"]["implications"] for c in capture["calls"] + for e in (c["answer"].get("elements") or []) + if "Coverage and achievement are distinct measures" in " ".join(e["properties"].get("implications") or [])) + assert len(stored) == 6 and "not only to IT" in stored + + +@pytest.mark.parametrize("text, expected", [ + ("a, b", ["a", "b"]), # a single line still splits + ("a; b", ["a", "b"]), + ("- one, with a comma", ["one, with a comma"]), # one bullet stays one item + ("- a, b\n- c", ["a, b", "c"]), + ("* a, b\n+ c", ["a, b", "c"]), + ("first line, with comma\nsecond", ["first line, with comma", "second"]), # multi-line: a line is an item + ("\n- a\n\n- b\n", ["a", "b"]), + ("", []), + (None, None), + (["x", " y "], ["x", "y"]), + ("-5, 6", ["-5", "6"]), # "-5" is not a bullet + ("- Item 1; - Item 2, Item 3", ["Item 1", "Item 2", "Item 3"]), # an inline bulleted list on one line +]) +def test_split_list_value(text, expected): + assert split_list_value(text) == expected + + +def test_spec_metadata_splitting_is_unchanged(): + assert split_tb_string("Display Name; Name, Title") == ["Display Name", "Name", "Title"] From ae03c751dc4ebecfde563b897e301fc5b76fa09d Mon Sep 17 00:00:00 2001 From: Dan Wolfson Date: Wed, 11 Nov 2026 21:53:21 +0000 Subject: [PATCH 2/4] fix(dr-egeria): wrapped continuations, intro lines and wrapped prose in list values (6.2.39 n1) Read-back n1 on 78ff098a. split_list_value's multi-line rule (_split_multiline): - With bullets: each bullet is an item. A non-bullet line after a bullet joins it only when it is a wrapped continuation -- indented, or starting in lower case after a bullet that did not end its sentence. Lines before the first bullet (an intro) and a closing sentence after the bullets are their own items (joining every non-bullet line would glue a closing sentence onto the last bullet, as in the Dr.Egeria samples' Examples block). - Without bullets: clearly wrapped prose -- every line break inside a sentence (the line before does not end in . ! ? ; : and is at least 60 characters, or the next line starts in lower case) -- is one item, lines joined with spaces; otherwise one item per line (a line list). - Commas are never split inside a multi-line value. Tests from real blocks copied verbatim from egeria-workspaces: the data-field- naming glossary Usage (wrapped prose -> 1 item), the dr-egeria-samples Examples line list (4 items), and the samples' mixed Examples block (intro + 4 bullets + closing sentence -> 6 items), plus continuation cases. Over 9,051 multi-line list-attribute blocks in egeria-workspaces-fs the result is the same as 78ff098a's. Release notes: the rule and "write list values as bullets". Signed-off-by: Dan Wolfson --- docs/release-notes/6.2.39.md | 6 +++ .../md_processing_utils/common_md_utils.py | 48 +++++++++++++++++-- .../data/dr_egeria/glossary_usage.txt | 3 ++ .../data/dr_egeria/samples_examples.txt | 5 ++ .../data/dr_egeria/samples_mixed_examples.txt | 7 +++ .../test_list_attribute_bullets.py | 43 ++++++++++++++++- 6 files changed, 108 insertions(+), 4 deletions(-) create mode 100644 tests/micro-tests/data/dr_egeria/glossary_usage.txt create mode 100644 tests/micro-tests/data/dr_egeria/samples_examples.txt create mode 100644 tests/micro-tests/data/dr_egeria/samples_mixed_examples.txt diff --git a/docs/release-notes/6.2.39.md b/docs/release-notes/6.2.39.md index 8720aa78..e0f170b1 100644 --- a/docs/release-notes/6.2.39.md +++ b/docs/release-notes/6.2.39.md @@ -14,7 +14,13 @@ pyegeria 6.2.39 fixes how Dr.Egeria reads list attributes. - A single-line value is still split on commas and semicolons ("a, b" is two items), including an inline bulleted list on one line ("- a; - b, c" is three). - **Behaviour change:** a single bullet on its own line, such as "- a, b", is now one item (it used to be two). + - In a block with bullets, an indented line, or a line starting in lower case after an unfinished bullet, is + that bullet's wrapped continuation; an intro line before the first bullet, or a closing sentence after the + bullets, is its own item. + - A block without bullets is one item per line, unless it is clearly wrapped prose (every line break falls + inside a sentence), which is one item. - Spec metadata (labels, valid values) is parsed as before. + - **Write list values as bullets**, one item per bullet: that is the form Dr.Egeria reads unambiguously. **Correcting stored data:** re-run the affected Dr.Egeria documents. An Update (or a Create that becomes an Update) sends the whole list with `mergeUpdate: true`, and Egeria's merge update replaces a property's value as a whole, so diff --git a/md_processing/md_processing_utils/common_md_utils.py b/md_processing/md_processing_utils/common_md_utils.py index 44eb5f99..63457c98 100644 --- a/md_processing/md_processing_utils/common_md_utils.py +++ b/md_processing/md_processing_utils/common_md_utils.py @@ -86,7 +86,8 @@ def split_list_value(text: Any) -> list | None: - A bulleted or multi-line value: each bullet (or line) is one item, verbatim -- a comma inside a bullet is part of the item ("- agreed with the depending domain, not set by IT alone" is one - item). A leading markdown bullet (`- `, `* `, `+ `) is stripped. + item). A leading markdown bullet (`- `, `* `, `+ `) is stripped. Wrapped continuations and + wrapped prose are handled by `_split_multiline`. - A single-line value is split on commas and semicolons ("a, b" is two items), including an inline bulleted list on one line ("- a; - b, c" is three); a single bullet on its own line is one item. @@ -101,8 +102,7 @@ def split_list_value(text: Any) -> list | None: if not lines: return [] if len(lines) > 1: - items = [_LIST_BULLET.sub('', line).strip() for line in lines] - return [item for item in items if item] + return _split_multiline(lines) line = lines[0] if _LIST_BULLET.match(line) and not _INLINE_BULLETS.search(line): return [_LIST_BULLET.sub('', line).strip()] # one bullet: one item, commas and all @@ -110,6 +110,48 @@ def split_list_value(text: Any) -> list | None: return [item for item in items if item] +_SENTENCE_END = re.compile(r'[.!?;:]["\')\]]*$') +#: A wrapped line is at least this long; a shorter line that ends without punctuation stands alone. +_WRAP_WIDTH = 60 + + +def _continues(previous: str, line: str) -> bool: + """Whether a non-bullet `line` after a bullet is that bullet's wrapped continuation: indented, or + starting in lower case after a bullet that did not end its sentence. Anything else stands alone.""" + if line[:1].isspace(): + return True + return line.lstrip()[:1].islower() and not _SENTENCE_END.search(previous.rstrip()) + + +def _split_multiline(lines: list) -> list: + """Items of a multi-line list value (6.2.39): + + - **With bullets:** each bullet is an item. A non-bullet line after a bullet joins it when it is a + wrapped continuation (indented, or starting in lower case); otherwise -- a closing sentence, say + -- it is its own item. Lines before the first bullet (an intro) are their own items. + - **Without bullets:** clearly wrapped prose -- every line break falls inside a sentence (the line + before it does not end in . ! ? ; : and is long, or the next line starts in lower case) -- is one + item, its lines joined with spaces. Otherwise each line is an item (a line list). + Commas are never split inside a multi-line value.""" + if not any(_LIST_BULLET.match(line) for line in lines): + if all(not _SENTENCE_END.search(a.rstrip()) and (b.lstrip()[:1].islower() or len(a.rstrip()) >= _WRAP_WIDTH) + for a, b in zip(lines, lines[1:])): + return [" ".join(line.strip() for line in lines)] + return [line.strip() for line in lines if line.strip()] + items: list = [] + in_bullet = False + for line in lines: + if _LIST_BULLET.match(line): + items.append(_LIST_BULLET.sub('', line).strip()) + in_bullet = True + elif in_bullet and _continues(items[-1], line): + items[-1] = f"{items[-1]} {line.strip()}" + else: + items.append(line.strip()) + in_bullet = False + return [item for item in items if item] + + def str_to_bool(value: str) -> bool: """Converts a string to a boolean value.""" return value.lower() in ("yes", "true", "t", "1") diff --git a/tests/micro-tests/data/dr_egeria/glossary_usage.txt b/tests/micro-tests/data/dr_egeria/glossary_usage.txt new file mode 100644 index 00000000..fdfdb549 --- /dev/null +++ b/tests/micro-tests/data/dr_egeria/glossary_usage.txt @@ -0,0 +1,3 @@ +This glossary is used by data architects and data stewards when naming new data fields. Build a field name by +combining a prime word (from the relevant subject area), zero or more modifiers (from the subject area or the +Common Modifiers folder), and a class word (from the subject area or the Common Class Words folder). diff --git a/tests/micro-tests/data/dr_egeria/samples_examples.txt b/tests/micro-tests/data/dr_egeria/samples_examples.txt new file mode 100644 index 00000000..2dad57e9 --- /dev/null +++ b/tests/micro-tests/data/dr_egeria/samples_examples.txt @@ -0,0 +1,5 @@ + + Create Glossary or + Update Glossary or + Create Term or + Update Term diff --git a/tests/micro-tests/data/dr_egeria/samples_mixed_examples.txt b/tests/micro-tests/data/dr_egeria/samples_mixed_examples.txt new file mode 100644 index 00000000..c233cee4 --- /dev/null +++ b/tests/micro-tests/data/dr_egeria/samples_mixed_examples.txt @@ -0,0 +1,7 @@ +Default values for key environment variables in the **Egeria Workspaces** environment: +* EGERIA_ROOT_PATH=/home/jovyan +* EGERIA_INBOX_PATH=loading-bay/dr-egeria-inbox +* EGERIA_OUTBOX_PATH=distribution-hub/dr-egeria-outbox +* EGERIA_LOCAL_QUALIFIER=EGERIA + +So place input files in the `loading-bay/dr-egeria-inbox` folder and look for output files in `distribution-hub/dr-egeria-outbox`. diff --git a/tests/micro-tests/test_list_attribute_bullets.py b/tests/micro-tests/test_list_attribute_bullets.py index 98dd9ce3..1a52df20 100644 --- a/tests/micro-tests/test_list_attribute_bullets.py +++ b/tests/micro-tests/test_list_attribute_bullets.py @@ -63,7 +63,8 @@ def test_egeria_holds_the_split_value_today(): ("- one, with a comma", ["one, with a comma"]), # one bullet stays one item ("- a, b\n- c", ["a, b", "c"]), ("* a, b\n+ c", ["a, b", "c"]), - ("first line, with comma\nsecond", ["first line, with comma", "second"]), # multi-line: a line is an item + ("First line, with comma\nSecond", ["First line, with comma", "Second"]), # a line list: a line is an item + ("first line, with comma\nsecond", ["first line, with comma second"]), # wrapped prose: one item ("\n- a\n\n- b\n", ["a", "b"]), ("", []), (None, None), @@ -77,3 +78,43 @@ def test_split_list_value(text, expected): def test_spec_metadata_splitting_is_unchanged(): assert split_tb_string("Display Name; Name, Title") == ["Display Name", "Name", "Title"] + + +# ── n1: mixed blocks and wrapped prose (real blocks from egeria-workspaces, copied verbatim) ── +# glossary_usage.txt <- coco-workbooks/1. coco-data-hub/data-field-naming/glossary.md:32-34 (Usage) +# samples_examples.txt <- exchange-quickstart/loading-bay/dr-egeria-samples/dr_egeria_intro_part1.md (Examples) +# samples_mixed_examples.txt <- exchange-quickstart/loading-bay/dr-egeria-samples/dr_egeria_intro_part3.md:83-89 + +def _block(name): + return (DATA / "dr_egeria" / name).read_text() + + +def test_wrapped_prose_is_one_item(): + items = split_list_value(_block("glossary_usage.txt")) + assert len(items) == 1 + assert items[0].startswith("This glossary is used by data architects") and "by combining a prime word" in items[0] + assert items[0].endswith("Common Class Words folder).") and "\n" not in items[0] + + +def test_a_plain_line_list_is_one_item_per_line(): + assert split_list_value(_block("samples_examples.txt")) == [ + "Create Glossary or", "Update Glossary or", "Create Term or", "Update Term"] + + +def test_a_mixed_block_keeps_intro_bullets_and_closing_line_apart(): + items = split_list_value(_block("samples_mixed_examples.txt")) + assert items[0] == "Default values for key environment variables in the **Egeria Workspaces** environment:" + assert items[1:5] == ["EGERIA_ROOT_PATH=/home/jovyan", "EGERIA_INBOX_PATH=loading-bay/dr-egeria-inbox", + "EGERIA_OUTBOX_PATH=distribution-hub/dr-egeria-outbox", "EGERIA_LOCAL_QUALIFIER=EGERIA"] + assert items[5].startswith("So place input files") and len(items) == 6 # a closing sentence stands alone + + +@pytest.mark.parametrize("text, expected", [ + ("- a bullet that wraps onto\n an indented next line\n- second", ["a bullet that wraps onto an indented next line", "second"]), + ("- a bullet that wraps and\ncontinues in lower case\n- second", ["a bullet that wraps and continues in lower case", "second"]), + ("- a finished bullet.\nlower case after a full stop\n- b", ["a finished bullet.", "lower case after a full stop", "b"]), + ("Intro line\n- a, b\n- c", ["Intro line", "a, b", "c"]), + ("Short one\nShort two", ["Short one", "Short two"]), +]) +def test_continuation_rules(text, expected): + assert split_list_value(text) == expected From e2e785686e1c880cd1f2b97cae4c594735afe8d4 Mon Sep 17 00:00:00 2001 From: Dan Wolfson Date: Wed, 11 Nov 2026 21:59:22 +0000 Subject: [PATCH 3/4] fix(dr-egeria): lower case alone never makes wrapped prose in a list value (6.2.39 n2) Read-back n2 on ae03c751: in a block without bullets, "the next line starts in lower case" alone counted as a wrap, so a short lower-case keyword list (crm / erp / data quality) became one item. Wrapped prose now needs every line but the last to be at least 60 characters long AND not end a sentence; a short line always stands alone. Tests: the three-line keyword list gives 3 items; the short "first line, with comma / second" case is a line list again; _continues is pinned -- inside a bulleted block, a lower-case line after a bullet that did not end its sentence continues it however short, and stands alone after a finished bullet or when capitalised. The real glossary Usage prose is still one item. Signed-off-by: Dan Wolfson --- docs/release-notes/6.2.39.md | 5 +++-- .../md_processing_utils/common_md_utils.py | 10 +++++----- .../micro-tests/test_list_attribute_bullets.py | 17 ++++++++++++++++- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/docs/release-notes/6.2.39.md b/docs/release-notes/6.2.39.md index e0f170b1..9ae43918 100644 --- a/docs/release-notes/6.2.39.md +++ b/docs/release-notes/6.2.39.md @@ -17,8 +17,9 @@ pyegeria 6.2.39 fixes how Dr.Egeria reads list attributes. - In a block with bullets, an indented line, or a line starting in lower case after an unfinished bullet, is that bullet's wrapped continuation; an intro line before the first bullet, or a closing sentence after the bullets, is its own item. - - A block without bullets is one item per line, unless it is clearly wrapped prose (every line break falls - inside a sentence), which is one item. + - A block without bullets is one item per line (a short line stands alone, even in lower case), unless it is + clearly wrapped prose -- every line but the last at least 60 characters long and not ending a sentence -- + which is one item. - Spec metadata (labels, valid values) is parsed as before. - **Write list values as bullets**, one item per bullet: that is the form Dr.Egeria reads unambiguously. diff --git a/md_processing/md_processing_utils/common_md_utils.py b/md_processing/md_processing_utils/common_md_utils.py index 63457c98..811a37cb 100644 --- a/md_processing/md_processing_utils/common_md_utils.py +++ b/md_processing/md_processing_utils/common_md_utils.py @@ -129,13 +129,13 @@ def _split_multiline(lines: list) -> list: - **With bullets:** each bullet is an item. A non-bullet line after a bullet joins it when it is a wrapped continuation (indented, or starting in lower case); otherwise -- a closing sentence, say -- it is its own item. Lines before the first bullet (an intro) are their own items. - - **Without bullets:** clearly wrapped prose -- every line break falls inside a sentence (the line - before it does not end in . ! ? ; : and is long, or the next line starts in lower case) -- is one - item, its lines joined with spaces. Otherwise each line is an item (a line list). + - **Without bullets:** clearly wrapped prose -- every line but the last is at least 60 characters + long and does not end a sentence (. ! ? ; :) -- is one item, its lines joined with spaces. Otherwise + each line is an item (a line list): a short line, even in lower case ("crm", "erp", "data + quality"), stands alone. Commas are never split inside a multi-line value.""" if not any(_LIST_BULLET.match(line) for line in lines): - if all(not _SENTENCE_END.search(a.rstrip()) and (b.lstrip()[:1].islower() or len(a.rstrip()) >= _WRAP_WIDTH) - for a, b in zip(lines, lines[1:])): + if all(not _SENTENCE_END.search(a.rstrip()) and len(a.rstrip()) >= _WRAP_WIDTH for a in lines[:-1]): return [" ".join(line.strip() for line in lines)] return [line.strip() for line in lines if line.strip()] items: list = [] diff --git a/tests/micro-tests/test_list_attribute_bullets.py b/tests/micro-tests/test_list_attribute_bullets.py index 1a52df20..32e46201 100644 --- a/tests/micro-tests/test_list_attribute_bullets.py +++ b/tests/micro-tests/test_list_attribute_bullets.py @@ -64,7 +64,7 @@ def test_egeria_holds_the_split_value_today(): ("- a, b\n- c", ["a, b", "c"]), ("* a, b\n+ c", ["a, b", "c"]), ("First line, with comma\nSecond", ["First line, with comma", "Second"]), # a line list: a line is an item - ("first line, with comma\nsecond", ["first line, with comma second"]), # wrapped prose: one item + ("first line, with comma\nsecond", ["first line, with comma", "second"]), # short lines: a line list ("\n- a\n\n- b\n", ["a", "b"]), ("", []), (None, None), @@ -118,3 +118,18 @@ def test_a_mixed_block_keeps_intro_bullets_and_closing_line_apart(): ]) def test_continuation_rules(text, expected): assert split_list_value(text) == expected + + +def test_a_short_lower_case_keyword_list_stays_a_list(): + """n2: lower case alone never makes a wrap in a block without bullets.""" + assert split_list_value("crm\nerp\ndata quality") == ["crm", "erp", "data quality"] + + +def test_a_short_lower_case_line_after_a_bullet_continues_it(): + """Pinned: inside a bulleted block, a non-bullet line in lower case after a bullet that did not end its + sentence is that bullet's wrapped continuation, however short; after a finished bullet it stands alone.""" + from md_processing.md_processing_utils.common_md_utils import _continues + assert _continues("- Service characteristics must be agreed", "erp") is True + assert split_list_value("- crm and\nerp\n- data quality") == ["crm and erp", "data quality"] + assert _continues("- Service characteristics are agreed.", "erp") is False + assert _continues("- crm", "Data Quality") is False From ae625e54a2a81a3001bf25a4f08895b647175d45 Mon Sep 17 00:00:00 2001 From: Dan Wolfson Date: Wed, 11 Nov 2026 22:00:37 +0000 Subject: [PATCH 4/4] chore(release): pyegeria 6.2.39 (includes the unpublished 6.2.38 fixes) Signed-off-by: Dan Wolfson --- docs/release-notes/6.2.39.md | 2 +- pyproject.toml | 2 +- uv.lock | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/release-notes/6.2.39.md b/docs/release-notes/6.2.39.md index 9ae43918..46910e7c 100644 --- a/docs/release-notes/6.2.39.md +++ b/docs/release-notes/6.2.39.md @@ -1,6 +1,6 @@ # pyegeria 6.2.39 -pyegeria 6.2.39 fixes how Dr.Egeria reads list attributes. +pyegeria 6.2.39 fixes how Dr.Egeria reads list attributes. It also carries the two 6.2.38 fixes (the DCAT Catalog spec runs with a search string; My Egeria's domain selection passes the GUID): 6.2.38 was tagged but not published to PyPI, so 6.2.39 follows 6.2.37 there. See 6.2.38.md. ## Fixed diff --git a/pyproject.toml b/pyproject.toml index 8ff50178..6dd8127c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ [project] name = "pyegeria" -version = "6.2.38" +version = "6.2.39" license = 'Apache-2.0' license-files = ["LICENSE"] authors = [{name = "Dan Wolfson", email = "dan.wolfson@pdr-associates.com"},] diff --git a/uv.lock b/uv.lock index 25f4407e..a4c33d19 100644 --- a/uv.lock +++ b/uv.lock @@ -2271,7 +2271,7 @@ sdist = { url = "https://files.pythonhosted.org/packages/f8/f6/8f49005d581cff883 [[package]] name = "pyegeria" -version = "6.2.38" +version = "6.2.39" source = { editable = "." } dependencies = [ { name = "altair" },