Skip to content

Commit b2fc2b3

Browse files
authored
feat(routines): inventory pinned G36 source trees (#71)
1 parent 02faadd commit b2fc2b3

7 files changed

Lines changed: 9341 additions & 18 deletions

File tree

.github/workflows/verify.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,33 @@ jobs:
1717
id: pin
1818
run: echo "rev=$(cat cxf-library/ENGINE_PIN)" >> "$GITHUB_OUTPUT"
1919

20+
- name: Read G36 source pins
21+
id: g36-source-pins
22+
run: |
23+
echo "release=$(cat cxf-library/routines/g36/SOURCE_RELEASE_PIN)" >> "$GITHUB_OUTPUT"
24+
echo "development=$(cat cxf-library/routines/g36/SOURCE_DEVELOPMENT_PIN)" >> "$GITHUB_OUTPUT"
25+
2026
- name: Checkout open-control engine at pin
2127
uses: actions/checkout@v4
2228
with:
2329
repository: jscott3201/open-control-engine
2430
ref: ${{ steps.pin.outputs.rev }}
2531
path: open-control
2632

33+
- name: Checkout Modelica Buildings release source at pin
34+
uses: actions/checkout@v4
35+
with:
36+
repository: lbl-srg/modelica-buildings
37+
ref: ${{ steps.g36-source-pins.outputs.release }}
38+
path: modelica-buildings-release
39+
40+
- name: Checkout Modelica Buildings development source at pin
41+
uses: actions/checkout@v4
42+
with:
43+
repository: lbl-srg/modelica-buildings
44+
ref: ${{ steps.g36-source-pins.outputs.development }}
45+
path: modelica-buildings-development
46+
2747
- name: svg fitment lint
2848
working-directory: cxf-library
2949
run: python3 tools/lint/svg_fitment.py
@@ -38,6 +58,13 @@ jobs:
3858
python3 -m unittest discover -s tools/lint/tests -v
3959
python3 tools/lint/routines.py
4060
61+
- name: Verify G36 source inventory
62+
working-directory: cxf-library
63+
run: |
64+
python3 tools/lint/g36_source.py --check \
65+
--release-root ../modelica-buildings-release \
66+
--development-root ../modelica-buildings-development
67+
4168
- uses: dtolnay/rust-toolchain@stable
4269

4370
- uses: Swatinem/rust-cache@v2

SCHEMA.md

Lines changed: 70 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ cxf-library/
2222
├── routines/ # planned control-routine catalog
2323
│ ├── registry.json # canonical class inventory
2424
│ ├── generated-registry.json # executable deployment inventory
25-
│ └── g36/ # G36 source pins, scope, and coverage
25+
│ └── g36/ # G36 pins, source inventory, scope, and coverage
2626
├── tools/verify/ # Rust harness: loads each rule into the engine, runs vectors
2727
```
2828

@@ -52,8 +52,9 @@ next free number, honoring any reservation.
5252
## Routine catalog
5353

5454
Routine contracts are independent of fault contracts. Nothing in this section
55-
changes a fault schema identifier or fault behavior. The L0 routine catalog is
56-
planned and non-executable.
55+
changes a fault schema identifier or fault behavior. The routine catalog is
56+
planned and non-executable. L1 adds source-tree evidence without adding a
57+
canonical class or executable deployment.
5758

5859
Pin ownership is split by purpose:
5960

@@ -73,20 +74,77 @@ retired and MUST be absent.
7374
`routines/registry.json` is the canonical class inventory. Its top-level object
7475
has exactly `schema` and `routines`; `schema` is
7576
`cxf-library/routine-registry/v2`. `routines` MUST be an array and MUST remain
76-
empty in L0. A scope anchor is not a canonical class. Actual class and
77-
subsequence identities are deferred to the pinned source inventory.
77+
empty in L1. A scope anchor is not a canonical class. The source inventory
78+
defined below records Git blobs; it does not identify Modelica classes or
79+
subsequences.
7880

7981
`routines/generated-registry.json` is the only inventory that may eventually
8082
drive routine execution. Its top-level object has exactly `schema` and
8183
`deployments`; `schema` is
8284
`cxf-library/generated-routine-registry/v1`. `deployments` MUST be an array and
83-
MUST remain empty in L0. The verifier's `--routines` mode reads this file,
85+
MUST remain empty in L1. The verifier's `--routines` mode reads this file,
8486
accepts the empty array, and rejects nonempty arrays until the generated
8587
deployment contract is implemented.
8688

8789
Canonical IDs MUST NOT encode fixed parameter values. Generated deployment IDs
8890
and row schemas are not defined by this version.
8991

92+
### `routines/g36/source-inventory.json` (`cxf-library/g36-source-inventory/v1`)
93+
94+
The source inventory records two independent Git-tree snapshots from
95+
`https://github.com/lbl-srg/modelica-buildings.git`. Its top-level object has
96+
exactly these keys in order: `schema`, `repository`, `source_root`,
97+
`inventory_scope`, `dependency_closure`, `license`, and `snapshots`.
98+
99+
- `schema` is `cxf-library/g36-source-inventory/v1`;
100+
- `repository` is `https://github.com/lbl-srg/modelica-buildings.git`;
101+
- `source_root` is `Buildings/Controls/OBC/ASHRAE/G36`;
102+
- `inventory_scope` is `source-root-regular-files`; and
103+
- `dependency_closure` is `not-inventoried`.
104+
105+
`license` has exactly `upstream_path`, `retained_path`, `git_blob_sha1`, and
106+
`sha256`, in that order. `upstream_path` is `Buildings/legal.html` and
107+
`retained_path` is `routines/g36/LICENSE-BUILDINGS.html`. The retained file MUST
108+
equal the Git blob bytes at both pins. `git_blob_sha1` uses
109+
`sha1:<40 lowercase hex>` and `sha256` uses `sha256:<64 lowercase hex>`.
110+
111+
`snapshots` contains exactly two rows, ordered `release` then `development`.
112+
Each row has exactly these keys in order: `role`, `revision`,
113+
`root_tree_sha1`, `file_count`, `total_bytes`, `modelica_file_count`,
114+
`package_order_count`, and `files`. `revision` MUST equal the corresponding pin
115+
file. `root_tree_sha1` is the Git tree ID for `source_root`, encoded as
116+
`sha1:<40 lowercase hex>`.
117+
118+
Each `files` row has exactly `path`, `mode`, `bytes`, `git_blob_sha1`, and
119+
`sha256`, in that order. Paths are full upstream repository-relative POSIX
120+
paths below `source_root`, sorted lexicographically and unique. Empty, `.`, and
121+
`..` path segments, absolute paths, backslashes, and control characters are
122+
invalid. Version 1 supports only regular `100644` Git blobs; other modes and
123+
object types MUST be rejected. `bytes` and both hashes are calculated from Git
124+
object bytes rather than working-tree files.
125+
126+
`file_count` is the number of file rows, and `total_bytes` is the sum of their
127+
`bytes` values. `modelica_file_count` counts paths ending in `.mo`.
128+
`package_order_count` counts paths ending in `/package.order`; `package.order`
129+
content is not parsed or validated. All files remain in the inventory whether
130+
or not another source file names them.
131+
132+
The release and development snapshots MUST remain separate. The inventory does
133+
not choose a snapshot for a future canonical class and MUST NOT use one as a
134+
fallback for the other. It inventories no dependency outside `source_root` and
135+
makes no claim about Modelica declarations, classes, package members,
136+
references, imports, inheritance, source-family mapping, or executable
137+
coverage.
138+
139+
`tools/lint/g36_source.py --write` regenerates the inventory and retained legal
140+
notice from two supplied checkouts. `--check` verifies each checkout origin and
141+
exact HEAD, derives all records through Git object commands, and compares both
142+
tracked artifacts byte-for-byte without rewriting them. JSON uses two-space
143+
indentation, the field order above, and one final newline. It contains no
144+
timestamp, branch name, checkout path, or moving source identity. A source pin
145+
change requires regenerating both snapshots; generation fails if the pinned
146+
legal blobs or bytes differ.
147+
90148
### `routines/g36/scope.json` (`cxf-library/g36-scope/v1`)
91149

92150
The scope manifest makes the Section 5 planning boundary discoverable without
@@ -131,7 +189,7 @@ The IDs, destinations, and reviewed planning dispositions are:
131189
| 5.21 | `G36-SCOPE-05-21` | `g36/plants/hot-water` | `independent-authoring` |
132190
| 5.22 | `G36-SCOPE-05-22` | `g36/fan-coil-units` | `upstream-partial` |
133191

134-
These dispositions classify the L0 source plan; they do not identify a source
192+
These dispositions classify the source plan; they do not identify a source
135193
class or prove implementation. Destinations are safe repository-relative POSIX
136194
paths below `g36/`. Absolute paths, backslashes, empty segments, `.` segments,
137195
and `..` segments are invalid. The manifest reserves destinations without
@@ -142,19 +200,19 @@ requiring placeholder directories.
142200
Coverage has exactly `schema`, `profile`, `status`, `scope`, and `claims`.
143201
`schema` is `cxf-library/g36-coverage/v2`; `profile` and `status` MUST equal
144202
`scope.json`; `scope` is `scope.json`; and `claims` MUST be an empty array in
145-
L0. Coverage does not repeat scope rows or inventory and makes no completeness,
203+
L1. Coverage does not repeat scope rows or inventory and makes no completeness,
146204
implementation, or evidence claim.
147205

148-
No `routine.cxf.jsonld` may appear below `routines/g36/` in L0. The retired
206+
No `routine.cxf.jsonld` may appear below `routines/g36/` in L1. The retired
149207
`routines/g36/generic/air-economizer-high-limits` fixed-variant path MUST be
150208
absent.
151209

152210
### Deferred routine contracts
153211

154212
Canonical typed routine artifact schemas, the generated deployment bundle
155-
schema, semantic sidecars, source inventory, specialization, and executable
156-
deployments are deferred. This version defines no routine interface, vectors,
157-
provenance, source map, or executable CXF contract.
213+
schema, source-to-family and class mapping, semantic sidecars, specialization,
214+
and executable deployments are deferred. This version defines no routine
215+
interface, vectors, source map, or executable CXF contract.
158216

159217
## Design stance (why the pieces split this way)
160218

routines/README.md

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
# Routine catalog
22

3-
Status: **planned and non-executable**.
3+
Status: **source-inventoried and non-executable**.
44

5-
The L0 catalog separates three inventories:
5+
The L1 catalog separates planning, source evidence, and future routine
6+
inventories:
67

78
- `g36/scope.json` records 22 Section 5 planning anchors and their intended
89
destinations. Scope IDs are not canonical class IDs, and the destinations do
910
not imply implemented classes or directories.
11+
- `g36/source-inventory.json` records every regular Git blob below the pinned
12+
upstream G36 source root in separate release and development snapshots.
13+
`g36/LICENSE-BUILDINGS.html` retains the legal notice shared by both pins.
1014
- `registry.json` is the canonical class inventory. It remains empty until the
11-
source inventory identifies actual classes and subsequences.
15+
class and subsequence inventory is defined.
1216
- `generated-registry.json` is the only future executable deployment inventory.
1317
It remains empty until the deployment bundle contract and specializer exist.
1418

@@ -25,7 +29,22 @@ Revision ownership is explicit:
2529
The pin files are authoritative source identities. There is no donor pin in the
2630
catalog contract. See the routine catalog section in
2731
[`SCHEMA.md`](../SCHEMA.md) for exact shapes, scope identities, and path rules.
28-
Validate the catalog boundary from the repository root:
32+
33+
The source inventory hashes Git object bytes, not working-tree files. It does
34+
not parse `package.order` or Modelica declarations and makes no claim about
35+
classes, package members, dependencies outside the source root, source-family
36+
mapping, or executable coverage.
37+
38+
Check the inventory against separate upstream checkouts whose HEADs match the
39+
pin files:
40+
41+
```sh
42+
python3 tools/lint/g36_source.py --check \
43+
--release-root /path/to/modelica-buildings-release \
44+
--development-root /path/to/modelica-buildings-development
45+
```
46+
47+
Run the remaining catalog gates from the repository root:
2948

3049
```sh
3150
python3 -m unittest discover -s tools/lint/tests -v
@@ -34,5 +53,5 @@ cargo run --manifest-path tools/verify/Cargo.toml -- --routines
3453
```
3554

3655
Canonical typed artifact schemas, generated deployment bundles, semantic
37-
sidecars, source inventory, specialization, and executable deployments remain
38-
deferred.
56+
sidecars, source-to-family and class mapping, specialization, and executable
57+
deployments remain deferred.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2+
<html>
3+
4+
<body>
5+
6+
<h1>License</h1>
7+
<p>
8+
Modelica Buildings Library. Copyright (c) 1998-2026
9+
Modelica Association,
10+
International Building Performance Simulation Association (IBPSA),
11+
The Regents of the University of California, through Lawrence Berkeley National Laboratory
12+
(subject to receipt of any required approvals from the U.S. Dept. of Energy) and
13+
contributors.
14+
All rights reserved.
15+
</p>
16+
<p>
17+
NOTICE. This Software was developed under funding from the U.S. Department of Energy and
18+
the U.S. Government consequently retains certain rights.
19+
As such, the U.S. Government has been granted for itself and others acting on its behalf
20+
a paid-up, nonexclusive, irrevocable, worldwide license in the Software
21+
to reproduce, distribute copies to the public, prepare derivative works, and
22+
perform publicly and display publicly, and to permit other to do so.
23+
</p>
24+
<p>
25+
Redistribution and use in source and binary forms, with or without modification,
26+
are permitted provided that the following conditions are met:
27+
</p>
28+
<ol>
29+
<li>
30+
Redistributions of source code must retain the above copyright notice,
31+
this list of conditions and the following disclaimer.
32+
</li>
33+
<li>
34+
Redistributions in binary form must reproduce the above copyright notice,
35+
this list of conditions and the following disclaimer
36+
in the documentation and/or other materials provided with the distribution.
37+
</li>
38+
<li>
39+
Neither the names of the Modelica Association,
40+
International Building Performance Simulation Association (IBPSA),
41+
the University of California,
42+
Lawrence Berkeley National Laboratory,
43+
U.S. Dept. of Energy,
44+
nor the names of its contributors
45+
may be used to endorse or promote products derived from this software
46+
without specific prior written permission.
47+
</li>
48+
</ol>
49+
<p>
50+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
51+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
52+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
53+
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
54+
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
55+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
56+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
58+
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
59+
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
60+
</p>
61+
<p>
62+
You are under no obligation whatsoever to provide any bug fixes, patches,
63+
or upgrades to the features, functionality or performance of the source code
64+
("Enhancements") to anyone; however, if you choose to make your Enhancements
65+
available either publicly, or directly to Lawrence Berkeley National
66+
Laboratory, without imposing a separate written license agreement for such
67+
Enhancements, then you hereby grant the following license: a non-exclusive,
68+
royalty-free perpetual license to install, use, modify, prepare derivative
69+
works, incorporate into other computer software, distribute, and sublicense
70+
such enhancements or derivative works thereof, in binary and source code form.
71+
</p>
72+
<p>
73+
Note: The license is a revised 3 clause BSD license with an ADDED paragraph
74+
at the end that makes it easy to accept improvements.
75+
</p>
76+
77+
</body>
78+
79+
</html>

0 commit comments

Comments
 (0)