From 11310d7885c6eb91c49b172f67858bfcf2f72de9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Oct 2026 16:19:26 +0000 Subject: [PATCH 1/4] Bump handlebars from 4.7.9 to 4.7.10 in /cdk Bumps [handlebars](https://github.com/handlebars-lang/handlebars.js) from 4.7.9 to 4.7.10. - [Release notes](https://github.com/handlebars-lang/handlebars.js/releases) - [Changelog](https://github.com/handlebars-lang/handlebars.js/blob/v4.7.10/release-notes.md) - [Commits](https://github.com/handlebars-lang/handlebars.js/compare/v4.7.9...v4.7.10) --- updated-dependencies: - dependency-name: handlebars dependency-version: 4.7.10 dependency-type: indirect ... Signed-off-by: dependabot[bot] --- cdk/package-lock.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cdk/package-lock.json b/cdk/package-lock.json index 1119935a..103600f7 100644 --- a/cdk/package-lock.json +++ b/cdk/package-lock.json @@ -3225,13 +3225,13 @@ "license": "ISC" }, "node_modules/handlebars": { - "version": "4.7.9", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.9.tgz", - "integrity": "sha512-4E71E0rpOaQuJR2A3xDZ+GM1HyWYv1clR58tC8emQNeQe3RH7MAzSbat+V0wG78LQBo6m6bzSG/L4pBuCsgnUQ==", + "version": "4.7.10", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.10.tgz", + "integrity": "sha512-P5VJMVM7qgBn6vjXMw8WG9uVI+ncf2pi72j4de4yz5ZULLj2RGqLYaKOYGsgyrViQ0tePOVlN1tDCCXXtFqXKg==", "dev": true, "license": "MIT", "dependencies": { - "minimist": "^1.2.5", + "minimist": "^1.2.8", "neo-async": "^2.6.2", "source-map": "^0.6.1", "wordwrap": "^1.0.0" From ab97494678b01ae3126fe5d21af99cbfe79d0fb6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Oct 2026 17:32:30 +0000 Subject: [PATCH 2/4] Bump handlebars from 4.7.9 to 4.7.10 in /client Bumps [handlebars](https://github.com/handlebars-lang/handlebars.js) from 4.7.9 to 4.7.10. - [Release notes](https://github.com/handlebars-lang/handlebars.js/releases) - [Changelog](https://github.com/handlebars-lang/handlebars.js/blob/v4.7.10/release-notes.md) - [Commits](https://github.com/handlebars-lang/handlebars.js/compare/v4.7.9...v4.7.10) --- updated-dependencies: - dependency-name: handlebars dependency-version: 4.7.10 dependency-type: indirect ... Signed-off-by: dependabot[bot] --- client/package-lock.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/package-lock.json b/client/package-lock.json index 93b97d8e..ac38fbcb 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -8332,13 +8332,13 @@ "license": "MIT" }, "node_modules/handlebars": { - "version": "4.7.9", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.9.tgz", - "integrity": "sha512-4E71E0rpOaQuJR2A3xDZ+GM1HyWYv1clR58tC8emQNeQe3RH7MAzSbat+V0wG78LQBo6m6bzSG/L4pBuCsgnUQ==", + "version": "4.7.10", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.10.tgz", + "integrity": "sha512-P5VJMVM7qgBn6vjXMw8WG9uVI+ncf2pi72j4de4yz5ZULLj2RGqLYaKOYGsgyrViQ0tePOVlN1tDCCXXtFqXKg==", "dev": true, "license": "MIT", "dependencies": { - "minimist": "^1.2.5", + "minimist": "^1.2.8", "neo-async": "^2.6.2", "source-map": "^0.6.1", "wordwrap": "^1.0.0" From 5a3c38491bc8a33a51092f68120417ac0d321acf Mon Sep 17 00:00:00 2001 From: AntoineGautier Date: Thu, 5 Nov 2026 09:27:22 +0100 Subject: [PATCH 3/4] Refactor sequence-doc toggles to per-configuration evaluation --- docs/selection-keys.md | 20 +- docs/sequence-doc.md | 52 ++- .../scripts/sequence-doc/src/generate_doc.py | 7 +- server/scripts/sequence-doc/src/mogrifier.py | 285 ++-------------- .../sequence-doc/src/sequence_payload.py | 59 ++-- server/scripts/sequence-doc/src/toggles.py | 195 +++++++++++ server/scripts/sequence-doc/src/utils.py | 13 - ...e 36-2021 (sequence selection source).docx | Bin 1210732 -> 1179103 bytes .../golden/mixed--ahu-co-rh.expected.txt | 3 + .../golden/mixed--co-rh-contrast.expected.txt | 1 + .../static/golden/mixed--rh-rh.expected.txt | 3 + .../golden/project--title24-si.expected.txt | 6 + .../sequence-doc/tests/test_mogrifier.py | 53 --- .../tests/test_mogrifier_patterns.py | 27 -- .../sequence-doc/tests/test_section_scope.py | 177 +++++++--- .../sequence-doc/tests/test_sequence_doc.py | 71 ++++ .../tests/test_sequence_payload.py | 39 ++- .../sequence-doc/tests/test_toggles.py | 320 ++++++++++++++++++ 18 files changed, 858 insertions(+), 473 deletions(-) create mode 100644 server/scripts/sequence-doc/src/toggles.py delete mode 100644 server/scripts/sequence-doc/tests/test_mogrifier.py delete mode 100644 server/scripts/sequence-doc/tests/test_mogrifier_patterns.py create mode 100644 server/scripts/sequence-doc/tests/test_toggles.py diff --git a/docs/selection-keys.md b/docs/selection-keys.md index 80cdd530..4f5cd125 100644 --- a/docs/selection-keys.md +++ b/docs/selection-keys.md @@ -229,15 +229,15 @@ The payload is the exchange format between the client and every consumer (sequen A sequence document covers one project. The sequence endpoint rejects a payload that does not contain exactly one project, until generating documents for several projects is specified, and a payload whose `schemaVersion` is not supported (HTTP 400, `checkPayload`). The pipeline checks the same (`sequence_payload.py`, on top of `ctrlflow.payload`, which checks the schema version for any consumer). -### Aggregation +### Evaluation -Toggles evaluate over the values of a project, gathered across its configurations: +A toggle is evaluated on each configuration of the project, and a section is kept if its toggle is true on at least one configuration, see "Evaluation" in [sequence-doc.md](sequence-doc.md). The values of a configuration are (`sequence_payload.configuration_values`): -- **System type** (e.g. `VAV` → `Buildings.Templates.ZoneEquipment`): the set of `template`s of the configurations with that `systemType`. -- **Key pattern** (see Mappings): the union of the `value`s of the matching keys in all configurations. Both origins are used, as on `main`. A `redeclare` is not read (see Mappings). -- **Project-level setting**: the `value` in `project.values`. +- **System type** (e.g. `VAV` → `Buildings.Templates.ZoneEquipment`): the `template` of the configuration, if it has that `systemType`. +- **Key pattern** (see Mappings): the `value` of the key of the template of the configuration. Both origins are used, as on `main`. A `redeclare` is not read (see Mappings). +- **Project-level setting**: the `value` in `project.values`, which is read on every configuration. -This reproduces the merge done by the client before #650. Merging now happens in the mogrifier (`sequence_payload.project_selections`, then `aggregate_patterns`). Which templates a toggle reads is set by the mappings: a section of a single system type uses short IDs of its template, and a section shared by several system types a key pattern or a combination of short IDs (see "Sections of System Types" in [sequence-doc.md](sequence-doc.md), #654). +Before #666, values were merged across the configurations, which lost the values that belong to the same configuration. Which templates a toggle reads is set by the mappings: a section of a single system type uses short IDs of its template, and a section shared by several system types a key pattern or a combination of short IDs (see "Sections of System Types" in [sequence-doc.md](sequence-doc.md), #654). ### Mappings @@ -251,11 +251,11 @@ alternatives = className { "|" className } A pattern is shorthand for the set of keys obtained by expanding the alternatives, e.g. `P.{A|B}-c.p` stands for `P.A-c.p` and `P.B-c.p`. Each expanded `rootClass` is a class where `elementPath` is declared (a template, or `Buildings.Templates.Data.AllSystems`), never an enclosing package. `{`, `|` and `}` cannot occur in a class name (no quoted class identifiers), so the expansion is unambiguous (`ctrlflow.keys`). Keys are then matched by equality. A test checks that every expanded key is the key under which the client stores the value of the element, with the default selections (`client/tests/sequence/mappings.test.ts`). -The mogrifier evaluates a toggle against the union of the values of all keys of the pattern. A condition on a subset of templates is expressed by the alternatives, or by a new mapping entry. +On a configuration, a toggle reads the key of the pattern whose `rootClass` is the template of the configuration. The alternatives of a pattern are templates of one system type (`server/scripts/sequence-doc/tests/test_section_scope.py`). A condition on a subset of templates is expressed by the alternatives, or by a new mapping entry. The `Current G36 Decisions` mappings are rewritten so that the generated document is unchanged: -- Each pattern lists the templates whose values are merged today. +- Each pattern lists the templates whose values were merged at the time. - Project-level settings use the keys of rule 1. - The five entries that read the class of a replaceable component (`PREHEAT`, `REHEAT`, `COOL`, `OA`, `TERM_HT`) read its `typ` parameter instead, and their value rows (`Modelica Path` column) use the enumeration literals, which match the classes one to one (`Coils.WaterBasedCooling` → `Types.Coil.WaterBasedCooling`). The mogrifier then reads `value` only, and the mappings test checks that every mapped element is not replaceable. @@ -283,7 +283,7 @@ Both are stored in `server/scripts/sequence-doc/tests/static/golden` and are reg - `ctrlflow.keys`: `parse_key`, and the key patterns of mappings files (`expand_pattern`, `is_pattern`). - `ctrlflow.payload`: `SCHEMA_VERSION`, `PayloadError`, `check_schema_version`. -How the values are gathered is left to each consumer: the sequence document takes the union of the values of a project across its configurations (`sequence_payload.py`), which an XLS editor of the values of each configuration must not do. +How the values are read is left to each consumer: the sequence document evaluates its toggles on each configuration of a project, and keeps a section if one configuration needs it (`sequence_payload.py`, `toggles.py`). ## Prerequisites @@ -311,7 +311,7 @@ Issues found by the probe, unrelated to quoted identifiers: ## Known limitations -- **Configurations of the same template.** The sequence document has one section per system type: the values of the configurations of the same template are merged, and a section is kept if any configuration of that type needs it (see "Sections of System Types" in [sequence-doc.md](sequence-doc.md)). +- **Configurations of the same template.** The sequence document has one section per system type: a section is kept if any configuration of that type needs it (see "Evaluation" and "Sections of System Types" in [sequence-doc.md](sequence-doc.md)). - **Replaceable short classes.** Before #620, short-class choices were written under one key (`…ShortClass-ShortClass`) and read under another (`…ShortClass-.FirstComponent`). The choice is now written and read at the short class element (rule 4, `T-ShortClass`). The parameters of the selected class are still displayed and keyed under the class name (`T-ShortClass.container`) rather than under the instance, and selecting another class does not change how the instance resolves. No template in `templates.json` uses a replaceable short class in the configuration panel. The display and resolution of short class instances are tracked separately. - **Spellings of quoted identifiers.** A source that spells a quoted identifier with and without a redundant escape (`'a\?'` and `'a?'`, `'a\"'` and `'a"'`) is not supported: ctrl-flow keeps identifiers as written, like Dymola and OCT, which reject such a source, although MLS §2.3.1 makes both spellings the same identifier. diff --git a/docs/sequence-doc.md b/docs/sequence-doc.md index b03a1545..7f872792 100644 --- a/docs/sequence-doc.md +++ b/docs/sequence-doc.md @@ -26,23 +26,46 @@ The annotation text and ONLY the annotation text (which includes the brackets) h ### Example Annotations: - + `[YES CO2]` – Keep this section if a CO2 sensor is present. Otherwise remove. - + `[NO CO2]` – Keep this section if a CO2 sensor is not present. Otherwise remove. - + `[EQUALS BSP RELIEFDMPR]` – Keep this section if the type of building pressure control system is an actuated relief damper, with relief fan(s). Otherwise remove. - + `[NOT_EQUALS BSP RELIEFDMPR]` - Keep this section if the type of building pressure control system is *not* an actuated relief damper, with relief fans(s). Otherwise remove. - + `[ANY BSP RETURNTRACK]` – Keep this section if the type of building pressure control system is a return fan, tracking measured supply and return airflow or a return fan, tracking calculated supply and return airflow. Otherwise remove. - + `[AND [any toggle] [any toggle]]` - Keep this section if both nested toggles would keep the section. The nested toggles can be any of these toggles including AND or OR. Otherwise remove. - + `[OR [any toggle] [any toggle]]` - Keep this section if one of the nested toggles would keep the section. The nested toggles can be any of these toggles including AND or OR. Otherwise remove. + + `[YES CO2]` – Keep this section if a configuration has a CO2 sensor. Otherwise remove. + + `[NO CO2]` – Keep this section if a configuration has no CO2 sensor. Otherwise remove. + + `[EQUALS BSP RELIEFDMPR]` – Keep this section if the type of building pressure control system of a configuration is an actuated relief damper, with relief fan(s). Otherwise remove. + + `[NOT_EQUALS BSP RELIEFDMPR]` - Keep this section if the type of building pressure control system of a configuration is *not* an actuated relief damper, with relief fans(s). Otherwise remove. + + `[ANY BSP RETURNTRACK]` – Keep this section if the type of building pressure control system of a configuration is a return fan, tracking measured supply and return airflow or a return fan, tracking calculated supply and return airflow. Otherwise remove. + + `[AND [any toggle] [any toggle]]` - Keep this section if both nested toggles are true on the same configuration. The nested toggles can be any of these toggles including AND, OR or NONE. Otherwise remove. + + `[OR [any toggle] [any toggle]]` - Keep this section if one of the nested toggles is true on a configuration. The nested toggles can be any of these toggles including AND, OR or NONE. Otherwise remove. + + `[NONE [any toggle]]` - Keep this section if the nested toggle is true on no configuration. Otherwise remove. + `[DELETE]` - Remove this section. Table annotations Example table toggles: + `[TABLE YES CO2]` - Keep the whole table if a CO2 sensor is present. Otherwise remove. - + `[ROW YES CO2]` - Keep this row if a CO2 sensor is present. Otherwise remove. + + `[ROW YES CO2]` or `[ROW [YES CO2]]` - Keep this row if a CO2 sensor is present. Otherwise remove. + `[COLUMN YES CO2]` - Keep this column if a CO2 sensor is present. Otherwise remove. + `[COLUMN AND [any toggle] [any toggle]]` - Keep this column if both nested toggles would keep the column. Otherwise remove. +### Evaluation + +An annotation is evaluated on each configuration of the project, with the values of the configuration, the project settings, and for a system type, the template of the configuration if it has that system type. **A section is kept if its annotation is true on at least one configuration.** A project without configurations is evaluated on the project settings alone. + +- Each key has one value on a configuration, so `NO` is the negation of `YES`, and `NOT_EQUALS` the negation of `EQUALS`. +- A key that a configuration does not have satisfies no annotation on it, including `NO` and `NOT_EQUALS`. Otherwise an AHU, which has no `have_CO2Sen`, would satisfy `[NO CO2]`. A system type that the project doesn't use has no keys: `YES`, `NO`, `EQUALS`, `NOT_EQUALS` and `ANY` are then false. In `[OR [YES CO2_PFBCV] [YES CO2_SFBCV]]`, a missing system type therefore doesn't delete the section. +- `AND` is true on a configuration if both operands are true on that configuration: two configurations that each satisfy one operand do not keep the section. For the same reason, an `AND` cannot combine keys of two system types, which no configuration has: `tests/test_section_scope.py` rejects it. A `NONE` operand is allowed, as it has the same value on all configurations. +- An invalid annotation or an unknown short ID is an error, and no document is generated. Otherwise a misspelled `NONE` operand would be false, and keep the section. + +**`NONE`.** `[NO CO2]` and `[NONE [YES CO2]]` differ when the configurations differ: + +| Zones | `[NO CO2]` | `[NONE [YES CO2]]` | +|---|---|---| +| All with a CO2 sensor | removed | removed | +| Some with a CO2 sensor | kept | removed | +| None with a CO2 sensor | kept | kept | +| No zone | removed | kept | + +`[NO CO2]` is for a section that applies to each zone without a sensor. `NONE` is for a section that one configuration is enough to rule out. This is the case of a section of a system that depends on the systems it serves: `[NONE [YES CO2]]` for the setpoint of an AHU that no zone resets, and `[NONE [ANY VAV DDDIS]]` for a totalization of the airflow of the boxes that needs all boxes to measure it. `[NONE [AND [YES A] [YES B]]]` is true if no configuration satisfies both operands. + +**Enclosing headings.** A section is removed with its heading, and otherwise only depends on its own annotation. A heading and a section it encloses can therefore be satisfied by different configurations. If they must be the same one, the annotation of the section states it with `AND`: under `[OR [OR [YES WIN] [YES OCC]] [YES CO2]]`, `[AND [OR [YES OCC] [YES CO2]] [NO WIN]]` needs a zone with a sensor and no window switch, whereas `[NO WIN]` would be satisfied by another zone than the one that keeps the heading. + ### Scope of an Annotation The section removed by an annotation depends on the style of the paragraph that starts with the annotation: @@ -95,21 +118,18 @@ Going back to the example annotation: These long paths can then be used to resolve the annotation in the script. -A key is `