Skip to content

Commit 83f468d

Browse files
chore: adopt org config set + pinned clang-format gate + one-time reformat (#54) (#55)
* chore(fluxgraph): adopt org config files + pinned clang-format CI gate Add the org template set fluxgraph was missing — .clang-format, .clang-tidy (HeaderFilterRegex for fluxgraph's src/include/server/tools/tests), .editorconfig, .gitattributes, justfile — and a cpp-format CI job using the setup-clang-tools action (SHA-verified static LLVM 18.1.8). Config + CI only; the one-time reformat follows in the next commit. * style(fluxgraph): apply org clang-format (pinned 18.1.8) [pure reformat] One-time mechanical reformat — adopt the org .clang-format style (Google base, 120 col, 4-space indent) across all 133 C++ files. Pure formatting (no logic changes); recorded in .git-blame-ignore-revs so git blame skips it. Previously fluxgraph ran clang-format with no .clang-format, so it used the tool's default style; this aligns it with the rest of the org. * chore(fluxgraph): add .git-blame-ignore-revs for the clang-format reformat Lets git blame skip the pure-formatting commit. Enable per clone: git config blame.ignoreRevsFile .git-blame-ignore-revs
1 parent d0fea8c commit 83f468d

140 files changed

Lines changed: 11334 additions & 12098 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-format

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
Language: Cpp
3+
BasedOnStyle: Google
4+
ColumnLimit: 120
5+
IndentWidth: 4
6+
AccessModifierOffset: -4
7+
...

.clang-tidy

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
# Shared provider clang-tidy config (mirrors the anolis runtime).
3+
# High-value signal only: keep diagnostics/analyzer/bugprone/performance, drop readability noise.
4+
Checks: >
5+
clang-diagnostic-*,
6+
clang-analyzer-*,
7+
performance-*,
8+
bugprone-*,
9+
-readability-*,
10+
-bugprone-macro-parentheses,
11+
-bugprone-easily-swappable-parameters
12+
# Note: consider re-enabling specific readability checks once bugprone/perf are clean.
13+
WarningsAsErrors: ""
14+
# Limit diagnostics to the repo's own source roots. ADJUST per provider to match
15+
# its layout (e.g. "src", "include", "tests"); this default covers the common case.
16+
# Generated protobuf sources live under build/ and are excluded — also disable
17+
# clang-tidy on the protobuf CMake target so compile_commands does not drag them in.
18+
HeaderFilterRegex: ".*/(src|include|server|tools|tests)/.*"
19+
FormatStyle: file
20+
...

.editorconfig

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Shared editor defaults for anolis providers. Copy to `.editorconfig` at the repo root.
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
insert_final_newline = true
8+
trim_trailing_whitespace = true
9+
indent_style = space
10+
11+
# C/C++ — matches .clang-format (IndentWidth: 4)
12+
[*.{c,cc,cpp,cxx,h,hh,hpp,hxx}]
13+
indent_size = 4
14+
15+
[*.{cmake,txt}]
16+
indent_size = 2
17+
18+
[CMakeLists.txt]
19+
indent_size = 2
20+
21+
[*.{yml,yaml,json}]
22+
indent_size = 2
23+
24+
[*.py]
25+
indent_size = 4
26+
27+
[justfile]
28+
indent_size = 4
29+
30+
# Markdown — keep trailing whitespace (hard line breaks)
31+
[*.md]
32+
trim_trailing_whitespace = false

.git-blame-ignore-revs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Reformat commits to skip in `git blame` (see git config blame.ignoreRevsFile).
2+
#
3+
# Enable once per clone: git config blame.ignoreRevsFile .git-blame-ignore-revs
4+
5+
# style(fluxgraph): apply org clang-format (pinned 18.1.8) [pure reformat]
6+
7da3d53386e6c4bd38427b25b61ae9e192a01de0

.gitattributes

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Normalize text files to LF across platforms.
2+
* text=auto eol=lf
3+
4+
# Keep Windows-native script line endings where expected.
5+
*.bat text eol=crlf
6+
*.cmd text eol=crlf
7+
*.ps1 text eol=crlf
8+
9+
# Common binary assets.
10+
*.png binary
11+
*.jpg binary
12+
*.jpeg binary
13+
*.gif binary
14+
*.bmp binary
15+
*.ico binary
16+
*.pdf binary
17+
*.zip binary
18+
*.7z binary
19+
*.bin binary
20+
*.hex binary
21+
*.elf binary

.github/workflows/ci.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,27 @@ jobs:
303303
python-version: '3.12'
304304
working-directory: '.'
305305

306+
cpp-format:
307+
name: C++ Formatting (clang-format)
308+
needs: [changes]
309+
if: needs.changes.outputs.code == 'true'
310+
runs-on: ubuntu-24.04
311+
timeout-minutes: 10
312+
steps:
313+
- name: Checkout
314+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
315+
- name: Install pinned clang-tools
316+
# SHA-verified static LLVM 18.1.8 clang-format on PATH — the org source of
317+
# truth, matching workstation-configs apps/clang-tools on dev boxes. See
318+
# anolishq/.github#69.
319+
uses: anolishq/.github/.github/actions/setup-clang-tools@43a0fe0a7feb87215f6e7677133be542ef6f1031 # setup-clang-tools
320+
- name: Check formatting
321+
run: git ls-files '*.c' '*.cc' '*.cpp' '*.cxx' '*.h' '*.hh' '*.hpp' '*.hxx' | xargs clang-format --dry-run --Werror
322+
306323
ok:
307324
name: ok
308325
if: always()
309-
needs: [changes, python-lint, python-typecheck, linux-matrix, strict-dimensional-validation, windows-core, windows-diagram, diagram-render-smoke, version-sync]
326+
needs: [changes, python-lint, python-typecheck, linux-matrix, strict-dimensional-validation, windows-core, windows-diagram, diagram-render-smoke, version-sync, cpp-format]
310327
runs-on: ubuntu-24.04
311328
timeout-minutes: 5
312329
steps:

examples/01_basic_transform/main.cpp

Lines changed: 47 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,52 +5,51 @@
55
#include <iostream>
66

77
int main() {
8-
// 1. Create namespaces and signal store
9-
fluxgraph::SignalNamespace sig_ns;
10-
fluxgraph::FunctionNamespace func_ns;
11-
fluxgraph::SignalStore store;
12-
13-
// 2. Build graph specification manually
14-
fluxgraph::GraphSpec spec;
15-
16-
// Define edge: voltage_in --[scale=2.0, offset=1.0]--> voltage_out
17-
fluxgraph::EdgeSpec edge;
18-
edge.source_path = "sensor.voltage_in";
19-
edge.target_path = "sensor.voltage_out";
20-
edge.transform.type = "linear";
21-
edge.transform.params["scale"] = 2.0;
22-
edge.transform.params["offset"] = 1.0;
23-
spec.edges.push_back(edge);
24-
25-
// 3. Compile graph
26-
fluxgraph::GraphCompiler compiler;
27-
auto program = compiler.compile(spec, sig_ns, func_ns);
28-
29-
// 4. Load into engine
30-
fluxgraph::Engine engine;
31-
engine.load(std::move(program));
32-
33-
// 5. Get signal IDs (these are your input/output "ports")
34-
auto input_sig = sig_ns.resolve("sensor.voltage_in");
35-
auto output_sig = sig_ns.resolve("sensor.voltage_out");
36-
37-
// 6. Simulation loop
38-
std::cout << "Simple Transform: y = 2*x + 1\n";
39-
std::cout << "================================\n";
40-
for (int i = 0; i < 5; ++i) {
41-
double input_val = i * 1.0;
42-
43-
// Write to input port
44-
store.write(input_sig, input_val, "V");
45-
46-
// Execute graph (dt doesn't affect stateless linear transform)
47-
engine.tick(0.1, store);
48-
49-
// Read from output port
50-
double output_val = store.read_value(output_sig);
51-
std::cout << "Input: " << input_val << "V -> Output: " << output_val
52-
<< "V\n";
53-
}
54-
55-
return 0;
8+
// 1. Create namespaces and signal store
9+
fluxgraph::SignalNamespace sig_ns;
10+
fluxgraph::FunctionNamespace func_ns;
11+
fluxgraph::SignalStore store;
12+
13+
// 2. Build graph specification manually
14+
fluxgraph::GraphSpec spec;
15+
16+
// Define edge: voltage_in --[scale=2.0, offset=1.0]--> voltage_out
17+
fluxgraph::EdgeSpec edge;
18+
edge.source_path = "sensor.voltage_in";
19+
edge.target_path = "sensor.voltage_out";
20+
edge.transform.type = "linear";
21+
edge.transform.params["scale"] = 2.0;
22+
edge.transform.params["offset"] = 1.0;
23+
spec.edges.push_back(edge);
24+
25+
// 3. Compile graph
26+
fluxgraph::GraphCompiler compiler;
27+
auto program = compiler.compile(spec, sig_ns, func_ns);
28+
29+
// 4. Load into engine
30+
fluxgraph::Engine engine;
31+
engine.load(std::move(program));
32+
33+
// 5. Get signal IDs (these are your input/output "ports")
34+
auto input_sig = sig_ns.resolve("sensor.voltage_in");
35+
auto output_sig = sig_ns.resolve("sensor.voltage_out");
36+
37+
// 6. Simulation loop
38+
std::cout << "Simple Transform: y = 2*x + 1\n";
39+
std::cout << "================================\n";
40+
for (int i = 0; i < 5; ++i) {
41+
double input_val = i * 1.0;
42+
43+
// Write to input port
44+
store.write(input_sig, input_val, "V");
45+
46+
// Execute graph (dt doesn't affect stateless linear transform)
47+
engine.tick(0.1, store);
48+
49+
// Read from output port
50+
double output_val = store.read_value(output_sig);
51+
std::cout << "Input: " << input_val << "V -> Output: " << output_val << "V\n";
52+
}
53+
54+
return 0;
5655
}

examples/02_thermal_mass/main.cpp

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -6,73 +6,73 @@
66
#include <iostream>
77

88
int main() {
9-
// 1. Setup
10-
fluxgraph::SignalNamespace sig_ns;
11-
fluxgraph::FunctionNamespace func_ns;
12-
fluxgraph::SignalStore store;
9+
// 1. Setup
10+
fluxgraph::SignalNamespace sig_ns;
11+
fluxgraph::FunctionNamespace func_ns;
12+
fluxgraph::SignalStore store;
1313

14-
// 2. Build graph with thermal mass model
15-
fluxgraph::GraphSpec spec;
14+
// 2. Build graph with thermal mass model
15+
fluxgraph::GraphSpec spec;
1616

17-
// Define thermal mass model
18-
fluxgraph::ModelSpec model;
19-
model.id = "chamber_thermal";
20-
model.type = "thermal_mass";
21-
model.params["temp_signal"] = std::string("chamber.temperature");
22-
model.params["power_signal"] = std::string("chamber.heater_power");
23-
model.params["ambient_signal"] = std::string("chamber.ambient_temp");
24-
model.params["thermal_mass"] = 1000.0; // J/K
25-
model.params["heat_transfer_coeff"] = 10.0; // W/K
26-
model.params["initial_temp"] = 25.0; // degC
27-
spec.models.push_back(model);
17+
// Define thermal mass model
18+
fluxgraph::ModelSpec model;
19+
model.id = "chamber_thermal";
20+
model.type = "thermal_mass";
21+
model.params["temp_signal"] = std::string("chamber.temperature");
22+
model.params["power_signal"] = std::string("chamber.heater_power");
23+
model.params["ambient_signal"] = std::string("chamber.ambient_temp");
24+
model.params["thermal_mass"] = 1000.0; // J/K
25+
model.params["heat_transfer_coeff"] = 10.0; // W/K
26+
model.params["initial_temp"] = 25.0; // degC
27+
spec.models.push_back(model);
2828

29-
// Optional: Add noise to temperature reading
30-
fluxgraph::EdgeSpec noise_edge;
31-
noise_edge.source_path = "chamber.temperature";
32-
noise_edge.target_path = "chamber.temperature_noisy";
33-
noise_edge.transform.type = "noise";
34-
noise_edge.transform.params["amplitude"] = 0.1; // +/- 0.1 degC noise
35-
noise_edge.transform.params["seed"] = static_cast<int64_t>(42);
36-
spec.edges.push_back(noise_edge);
29+
// Optional: Add noise to temperature reading
30+
fluxgraph::EdgeSpec noise_edge;
31+
noise_edge.source_path = "chamber.temperature";
32+
noise_edge.target_path = "chamber.temperature_noisy";
33+
noise_edge.transform.type = "noise";
34+
noise_edge.transform.params["amplitude"] = 0.1; // +/- 0.1 degC noise
35+
noise_edge.transform.params["seed"] = static_cast<int64_t>(42);
36+
spec.edges.push_back(noise_edge);
3737

38-
// 3. Compile and load
39-
fluxgraph::GraphCompiler compiler;
40-
auto program = compiler.compile(spec, sig_ns, func_ns);
38+
// 3. Compile and load
39+
fluxgraph::GraphCompiler compiler;
40+
auto program = compiler.compile(spec, sig_ns, func_ns);
4141

42-
fluxgraph::Engine engine;
43-
engine.load(std::move(program));
42+
fluxgraph::Engine engine;
43+
engine.load(std::move(program));
4444

45-
// 4. Get signal IDs (input/output ports)
46-
auto heater_sig = sig_ns.resolve("chamber.heater_power");
47-
auto ambient_sig = sig_ns.resolve("chamber.ambient_temp");
48-
auto temp_sig = sig_ns.resolve("chamber.temperature");
49-
auto temp_noisy_sig = sig_ns.resolve("chamber.temperature_noisy");
45+
// 4. Get signal IDs (input/output ports)
46+
auto heater_sig = sig_ns.resolve("chamber.heater_power");
47+
auto ambient_sig = sig_ns.resolve("chamber.ambient_temp");
48+
auto temp_sig = sig_ns.resolve("chamber.temperature");
49+
auto temp_noisy_sig = sig_ns.resolve("chamber.temperature_noisy");
5050

51-
// 5. Initialize ambient temperature
52-
store.write(ambient_sig, 20.0, "degC");
51+
// 5. Initialize ambient temperature
52+
store.write(ambient_sig, 20.0, "degC");
5353

54-
// 6. Simulation: heat chamber for 5 seconds, then turn off
55-
std::cout << "Thermal Mass Simulation\n";
56-
std::cout << "=======================\n";
57-
std::cout << std::fixed << std::setprecision(2);
54+
// 6. Simulation: heat chamber for 5 seconds, then turn off
55+
std::cout << "Thermal Mass Simulation\n";
56+
std::cout << "=======================\n";
57+
std::cout << std::fixed << std::setprecision(2);
5858

59-
for (double t = 0; t <= 10.0; t += 0.5) {
60-
// Control heater: on for first 5 seconds, off after
61-
double heater_power = (t < 5.0) ? 500.0 : 0.0;
62-
store.write(heater_sig, heater_power, "W");
59+
for (double t = 0; t <= 10.0; t += 0.5) {
60+
// Control heater: on for first 5 seconds, off after
61+
double heater_power = (t < 5.0) ? 500.0 : 0.0;
62+
store.write(heater_sig, heater_power, "W");
6363

64-
// Execute physics
65-
engine.tick(0.5, store);
64+
// Execute physics
65+
engine.tick(0.5, store);
6666

67-
// Read output ports
68-
double temp = store.read_value(temp_sig);
69-
double temp_noisy = store.read_value(temp_noisy_sig);
67+
// Read output ports
68+
double temp = store.read_value(temp_sig);
69+
double temp_noisy = store.read_value(temp_noisy_sig);
7070

71-
std::cout << "t=" << std::setw(5) << t << "s "
72-
<< "Heater=" << std::setw(5) << heater_power << "W "
73-
<< "Temp=" << std::setw(6) << temp << " degC "
74-
<< "Noisy=" << std::setw(6) << temp_noisy << " degC\n";
75-
}
71+
std::cout << "t=" << std::setw(5) << t << "s "
72+
<< "Heater=" << std::setw(5) << heater_power << "W "
73+
<< "Temp=" << std::setw(6) << temp << " degC "
74+
<< "Noisy=" << std::setw(6) << temp_noisy << " degC\n";
75+
}
7676

77-
return 0;
77+
return 0;
7878
}

0 commit comments

Comments
 (0)