Skip to content

Sequence document: evaluate toggles per configuration #666

Closed

Description

@AntoineGautier

Problem

Toggles are evaluated against the union of the values of a key across the configurations of a project (project_selections, aggregate_patterns). The union loses which values belong to the same configuration:

  • YES, EQUALS and ANY keep a section if some configuration satisfies them, but NO and NOT_EQUALS only keep it if all configurations do. With CO2 → [True, False], [NO CO2] deletes the section, contrary to docs/sequence-doc.md: "a section of a system type is kept if any configuration of that type needs it."
  • AND checks its operands separately: [AND [YES A] [YES B]] is true if one configuration has A and another has B.
  • "No configuration satisfies this" cannot be stated on purpose. AHU sections need it, and only get it today from the behaviour of NO.

Specification

Evaluation. A toggle, including its AND and OR, is evaluated on each configuration of the project, with:

  • the values of the configuration;
  • the values of project.values;
  • for a system type, the template of the configuration if it has that systemType.

A section is kept if its toggle is true on at least one configuration. A project without configurations is evaluated on project.values alone.

Absent keys. A key that the configuration does not have satisfies no leaf, including NO and NOT_EQUALS. Otherwise an AHU configuration, which has no have_CO2Sen, would satisfy [NO CO2].

Leaves. Each key has one value, so NO is the negation of YES and NOT_EQUALS the negation of EQUALS, on keys that are present.

NONE (new). [NONE [toggle]] is true if the nested toggle is false on every configuration. It has the same value on all configurations, so it can be an operand of AND or OR. [NO CO2] and [NONE [YES CO2]] differ: the first is true if some configuration has no CO2 sensor, the second if no configuration has one. A project without configurations of the system type satisfies NONE.

Enclosing headings. Unchanged: a section is removed with its heading, and otherwise only depends on its own toggle. A heading and a section it encloses can be satisfied by different configurations. If they must be the same one, the toggle of the section states it with AND.

Invalid toggles. An invalid toggle or an unknown short ID raises an error, instead of logging and deleting the section. Inside NONE, "delete" would be negated and keep the section. The "keep" of NOT_EQUALS on an unknown short ID goes away.

Parsing. Toggles are parsed by balanced brackets. This removes the limit that a nested toggle is only parsed as the first operand of AND or OR.

Tasks

Evaluator (server/scripts/sequence-doc)

  • Parse toggles into a tree, by balanced brackets, including TABLE, ROW and COLUMN.
  • Evaluate the tree per configuration, and add NONE.
  • Replace project_selections and aggregate_patterns by the per-configuration values. A key pattern is read through the key of the template of the configuration. Keep UNITS on project.values.
  • Remove the helpers of utils.py that become unused, and their tests.
  • Update the docstrings of mogrifier.py.

Source document (Current G36 Decisions)

  • [NOT_EQUALS VAV DDDIS] (Supply Fan Start/Stop, Totalize current airflow rate) → [NONE [ANY VAV DDDIS]]
  • [NO CO2] (7 AHU sections, Minimum Outdoor Air Control) → [NONE [YES CO2]]
  • [AND [NO CO2] [NO OCC]] (2 AHU sections) → [NONE [OR [YES CO2] [YES OCC]]]
  • [AND [AND [NO CO2] [NO OCC]] [NO WIN]] (1 AHU section) → [NONE [OR [OR [YES CO2] [YES OCC]] [YES WIN]]]
  • [NO WIN] (under [OR [OR [YES WIN] [YES OCC]] [YES CO2]]) → [AND [OR [YES OCC] [YES CO2]] [NO WIN]]

The other zone toggles with NO ([AND [NO WIN] [NO OCC]] and the three-sensor ANDs) are not under a positive heading and do not change.

Tests

  • Each operator on a project with configurations that differ, including [NO k] and [NOT_EQUALS k v] with mixed values.
  • AND on two configurations that each satisfy one operand only: false.
  • [NO CO2] and [NONE [YES CO2]] on mixed, all-true and all-false zones, and on a project without zones.
  • NONE as first and second operand of AND and OR.
  • Absent key: no leaf is satisfied.
  • Invalid toggle and unknown short ID: an error is raised, also inside NONE.
  • test_section_scope.py: accept NONE and nested operands. Reject an AND whose operands read two system types (a NONE operand excepted), since it could never be true, and a pattern spanning two system types.
  • Regenerate the expected texts with UPDATE_GOLDEN=1 and review the diff.

Documentation

  • docs/sequence-doc.md: evaluation rule, NONE and the [NO CO2] / [NONE [YES CO2]] difference, how to require the same configuration as the heading. Remove the first-operand limit, rewrite the absent system type limit (NOT_EQUALS no longer keeps the section) and the sentence on merged configurations.
  • docs/selection-keys.md: rewrite "Aggregation" and the sentence of "Mappings" on the union of the values of a pattern.

Acceptance criteria

  • In a project with a zone with a CO2 sensor and a zone without, a [NO CO2] section is kept.
  • In the same project, the AHU sections keep [YES CO2] "MinOAsp shall be reset…" and remove [NONE [YES CO2]] "MinOAsp shall be equal to DesMinOA*."
  • [AND [YES A] [YES B]] is kept only if one configuration satisfies both.
  • A project of zones with only a CO2 sensor keeps the [AND [OR [YES OCC] [YES CO2]] [NO WIN]] paragraph.
  • Expected texts change only for mixed payloads and for AHU payloads without zones, and the diff is reviewed. In the latter, the NONE sections are now kept.
  • All tests of server/scripts/sequence-doc and server/scripts/ctrlflow pass in the ctrl-flow container, and client/tests/sequence/mappings.test.ts passes.
  • No expected text is edited by hand.

Out of scope

  • The wording of zone sections kept together in a mixed project, e.g. "Vmin* shall be equal to Vmin." and "…except as noted in 3.2.1.3.h."
  • A mapping for DDDIS, not implemented in Templates: [NONE [ANY VAV DDDIS]] stays true until it is.

Activity

  1. AntoineGautier commented on Nov 16, 2026

    @AntoineGautier
    CollaboratorAuthor

    Closed with #671.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions