Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/corpus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Corpus

# The public corpus of real Loxone configs (crates/loxone-config/tools/
# corpus-manifest.json) and the pinned external references
# (docs/references.json). Neither is committed — most of it carries no
# license to redistribute — so this job downloads them, verifies their
# hashes and runs the corpus tests. Weekly, and on demand.

on:
schedule:
- cron: "17 5 * * 1"
workflow_dispatch:
pull_request:
paths:
- "crates/loxone-config/tools/fetch-corpus.py"
- "crates/loxone-config/tools/corpus-manifest.json"
- "tools/fetch-refs.py"
- "docs/references.json"
- ".github/workflows/corpus.yml"

env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0

jobs:
corpus:
name: Corpus tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7

- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable

- name: Cache cargo
uses: actions/cache@v6
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

# Keyed on the manifest: the sources are fetched once per manifest
# version, not every week.
- name: Cache corpus
uses: actions/cache@v6
with:
path: crates/loxone-config/corpus/web
key: corpus-${{ hashFiles('crates/loxone-config/tools/corpus-manifest.json') }}

- name: Fetch and verify the corpus
working-directory: crates/loxone-config
run: python3 -I tools/fetch-corpus.py corpus/web

- name: Corpus tests
working-directory: crates/loxone-config
env:
LOXL_CORPUS: corpus/web
run: cargo test --release -p loxone-config --test corpus --test roundtrip --no-fail-fast

references:
name: Reference drift
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7

# Exit 1 when Loxone republished a pinned document: re-read it,
# carry what changed into our docs, then `tools/fetch-refs.py --update`.
- name: Check pinned references
run: python3 -I tools/fetch-refs.py --check
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
/target

# External references, downloaded by tools/fetch-refs.py (links only, never committed)
/refs
__pycache__/
9 changes: 9 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,15 @@ Other commands that may prompt: `scp`/`ssh` — use `-o BatchMode=yes`; `apt-get
```
5. Verify all changes committed and pushed before ending the session

## External references

The official Loxone documents (Communicating with the Miniserver, Structure File, User Management, ...) and
the community sources are listed in [docs/references.json](docs/references.json): links only, never the
files. `tools/fetch-refs.py` downloads them into `refs/` (gitignored) and checks each pinned sha256, so a
silently republished document shows up as `DRIFT`. Read a protocol fact there before guessing it; write it
into our docs in our own words, citing the reference id and section. The public test corpus of real configs
is `crates/loxone-config/tools/fetch-corpus.py` (see that crate's AGENTS.md).

## Issue Tracking

Issues live in GitHub Issues (`gh issue list`, `gh issue create`). Do not keep TODO lists in markdown files.
1 change: 1 addition & 0 deletions changelog.d/external-resources.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- **Example library** of real Loxone Config projects in `crates/loxone-config/examples/library/`: each with its source, license, Lox Logic view and page drawings, so you can see what a config looks like as code
1 change: 1 addition & 0 deletions changelog.d/external-resources.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- **`loxl scan`** (and `lox logic scan`) also finds the project's creator and phone number in the document properties, and `--redact` replaces them; before, a shared copy kept both
7 changes: 5 additions & 2 deletions crates/loxone-config/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ toolchain (the loop, hard rules, error remedies).
cargo test -p loxone-config # unit, pipeline, roundtrip
cargo clippy -p loxone-config --all-targets # must be warning-free
cargo fmt --check
LOXL_CORPUS=<dir> cargo test -p loxone-config --test roundtrip # opt-in: real configs
tools/fetch-corpus.py && LOXL_CORPUS=corpus/web cargo test --release -p loxone-config --test corpus --test roundtrip # opt-in: the public corpus
cargo run --bin loxl -- help # the CLI (also: lox logic help)
```

Expand All @@ -22,7 +22,10 @@ cargo run --bin loxl -- help # the CLI (also: lox logic help)
Never hand-edit `*.lock.json` beyond the documented operations.
- **Never commit real Miniserver configs** (personal data). Synthetic
fixtures live in `examples/configs/`; real ones go in an untracked corpus
dir referenced via `LOXL_CORPUS`.
dir referenced via `LOXL_CORPUS` (the public one: `tools/fetch-corpus.py`,
pinned by `tools/corpus-manifest.json`). The only real configs in the
repository are the redistributable, redacted ones of `examples/library/`,
each with its `SOURCE.md` and `LICENSE`.
- The builtin connector table (`src/connectors.rs`) only accepts
**live-verified** entries — the growth workflow is in
[docs/implementation.md](docs/implementation.md).
Expand Down
17 changes: 16 additions & 1 deletion crates/loxone-config/docs/implementation.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Three layers, all run by `cargo test`:
configs, plus an opt-in corpus:

```sh
LXC_CORPUS=~/loxone-backups cargo test --test roundtrip
LOXL_CORPUS=~/loxone-backups cargo test --test roundtrip
```

Real configs contain personal data (addresses, key hashes) — **never
Expand All @@ -57,6 +57,21 @@ Three layers, all run by `cargo test`:
adding a fixture). Every new real config is a
free test case: drop it in the corpus dir and run the suite.

The public corpus (~150 configs from Loxone's KB samples, LoxWiki and
GitHub) is reproducible from its committed manifest,
[`tools/corpus-manifest.json`](../tools/corpus-manifest.json): every
file with its source (GitHub pinned to a commit), sha256 and license.

```sh
tools/fetch-corpus.py # download into corpus/web, verify hashes
LOXL_CORPUS=corpus/web cargo test --release --test corpus --test roundtrip
tools/fetch-corpus.py --discover # search the sources afresh, rewrite the manifest
```

The *Corpus* workflow runs the same weekly and on demand. Configs whose
license allows redistributing them also go into the browsable
[example library](../examples/library/README.md).

QA bar for changes: `cargo test && cargo clippy --all-targets && cargo fmt
--check`, all clean.

Expand Down
6 changes: 6 additions & 0 deletions crates/loxone-config/docs/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ types) contradict each other. Results and methodology:
managed-type blocks adopt; all 8 refusals are `Inv=`.
Remaining leads: loxforum.com and the Loxone Library (both need
free-account logins).
- [x] Corpus pinned (2026-10-31): `tools/corpus-manifest.json` records every
file's source (GitHub at a commit), sha256 and license, so
`tools/fetch-corpus.py` reproduces the corpus exactly (149 files);
the weekly *Corpus* workflow runs the corpus tests on it. The
redistributable configs (MIT, BSD-3) form the browsable
[example library](../examples/library/README.md).
- [x] Second 2026-08-25 batch: `LightController2` (75 connectors, the
house's flagship type), `Switch2Button`, `CentralShade`,
`CentralLight`, `Code16` — modern house-V273 element orders, zero
Expand Down
1 change: 1 addition & 0 deletions crates/loxone-config/examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ is visible in a committed, test-pinned example. Where to look:
| [logic/pool.loxl](logic/pool.loxl) | the narrative showcase: a template with an instance, an expression argument, a `min` unit value, an expression wire, arithmetic folded into a `Formula` block (D35), two sim scenarios |
| [logic/sprachtour.loxl](logic/sprachtour.loxl) | the systematic language tour — every construct the two above do not cover (see below) |
| [logic/lifecycle/](logic/lifecycle/) | `moved` and `removed`, in three staged modules — the two transient statements no permanent module can carry; narrated by `cargo run --example lifecycle` |
| [library/](library/) | real third-party configs we may redistribute, redacted, each with its source, license, decompiled view and page drawings |
| [project/](project/) | a `lox.toml` project: fragment directory with one file per page (D25/D28), committed lockfile and output |

The tour covers, in order: string and numeric `let` constants; the full
Expand Down
40 changes: 40 additions & 0 deletions crates/loxone-config/examples/library/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Example library

Real Loxone Config projects, each with the Lox Logic view of its logic pages, so
you can see what a config looks like as code. Every entry is a config whose
license allows redistributing it:

| Entry | What it does | Config | License |
|---|---|---|---|
| [nibe-heat-pump](nibe-heat-pump/) | heating handover to a Nibe heat pump, heating stop, hot-water boost | 9.3 | MIT |
| [loxcall](loxcall/) | SIP call states parsed by a Program block | 12.1 | BSD-3-Clause |

Each directory holds:

- `SOURCE.md`: where the file comes from (repository, commit, sha256 of the
original), the author, the license, and every change made to it;
- `LICENSE`: the upstream license text;
- `<name>.Loxone`: the config, with personal data replaced by placeholders
(`loxl scan --redact`). For reading only, never for uploading;
- `logic/<page>.loxl`: the full decompiled view (`loxl decompile --out-dir logic`);
- `<page>.svg`: each logic page as Loxone Config draws it (`loxl render`).

## Adding an entry

Only configs we may redistribute: our own, ones under a license that allows it
(MIT, BSD, Apache, CC-BY, CC0, ...), or ones whose author gave written
permission (link the permission in `SOURCE.md`). Everything else stays in the
local test corpus (`tools/fetch-corpus.py`, see
[docs/implementation.md](../../docs/implementation.md)).

```sh
mkdir examples/library/<name> && cd examples/library/<name>
loxl scan --redact <original.Loxone> --out <name>.Loxone # must leave 0 findings
loxl decompile --out-dir logic <name>.Loxone
loxl render <name>.Loxone --page "<Page>" --out <page>.svg # one per logic/<page>.loxl
# then write SOURCE.md and copy the upstream LICENSE
```

`tests/library.rs` checks that every entry names its source and license and that
the views and drawings are what the current decompiler and renderer produce. When
either changes, regenerate them with the `decompile` and `render` lines above.
29 changes: 29 additions & 0 deletions crates/loxone-config/examples/library/loxcall/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2021, Smarteon Systems
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 changes: 24 additions & 0 deletions crates/loxone-config/examples/library/loxcall/SOURCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Loxcall (Smarteon)

Call-state handling for Smarteon's Loxcall SIP integration: a Program block parses
the call state text from a virtual text input into memories (state, user, device)
and comparators that raise "start" and "ringing". Saved by Loxone Config 12.1
(`ConfigVersion 12010716`).

- Source: https://github.com/Smarteon/community/blob/a2d76ac61783d3f4851367143d7f2f15cc528f20/loxcall/loxcall.Loxone
- Commit: `a2d76ac61783d3f4851367143d7f2f15cc528f20` (sha256 of the original:
`ac2521613fa000fa88453e793bbeed7551b9f95b8e803056b898da412c9cfa3b`)
- Author: Smarteon Systems s.r.o.
- License: BSD-3-Clause, see [LICENSE](LICENSE)
- Changes: the line `<!-- Normalized by Smarteon Systems -->` removed (Loxone
Config never writes comments, and the parser refuses them), then
placeholders for 9 values with `loxl scan --redact`: the document's creator,
phone, mail address and coordinates, two user names, the Miniserver's serial
and remote-access address. Nothing else.

Files: [loxcall.Loxone](loxcall.Loxone) (the edited config),
[logic/loxcall.loxl](logic/loxcall.loxl) (its Lox Logic view),
[loxcall.svg](loxcall.svg) (the page as drawn).

Worth a look: the comparator `START` has a wire on `Input1` and still keeps a
constant (`Def="2"`) there from before the wire was drawn; the view prints both.
58 changes: 58 additions & 0 deletions crates/loxone-config/examples/library/loxcall/logic/loxcall.loxl
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
page "_LoxCall"

extern callstateoutput_2 = InputRef(uuid: "1713f389-0398-feb1-ffff4268f6c1aee9") # mirrors Memory "_CallStateOutput"
extern callstateoutput_3 = InputRef(uuid: "1713f389-0398-fec1-ffff4268f6c1aee9") # mirrors Memory "_CallStateOutput"
extern callstate = VirtualTextIn(iname: "VTI1") # periphery

program = Code16(
TI1: callstate.TQ,
)

start = Equal(
Input1: 2,
Input1: callstateoutput_2.AQ,
Input2: 2,
)

ringing = Equal(
Input1: callstateoutput_3.AQ,
Input2: 1,
)

callstateoutput = Memory(
Input: program.AQ1,
)

callstateuser = Memory(
Input: program.TQ1,
)

callstatedevice = Memory(
Input: program.TQ2,
)

callstatenumber = Memory(
Input: program.TQ3,
)

callonimpuls = Memory(
Input: call_2.Qon,
)

calloffimpuls = Memory(
Input: call_2.Qoff,
)

callactive = Memory(
Input: call_2.Q,
)

call = Or(
I1: start.Q,
I2: ringing.Q,
)

call_2 = PushButton(
"CALL",
On: call.Q,
)
Loading
Loading