fix(overlay): restore TS/Python parity for node-level network templates - #114
fix(overlay): restore TS/Python parity for node-level network templates#114pparage wants to merge 3 commits into
Conversation
…ntext
Ports the canonical Jinja form `{{ bridge_base + team_id }}` and the
node-level cidr/bridge/gateway_template -> cidr/bridge/gateway rendering
from the TS operator, restoring TS/Python vector parity. bridge_base
falls back to 140 when null or absent.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2af7d5114a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
|
|
||
| # Canonical schema form: Jinja-ish `{{ bridge_base + team_id }}`. | ||
| _JINJA_RE = re.compile(r"\{\{\s*([^{}]+?)\s*\}\}") |
There was a problem hiding this comment.
Preserve unrelated Jinja expressions
Restrict this matcher to the supported team_id/bridge_base arithmetic grammar. Because it currently captures every {{ ... }} block, replicated config.name_template and network ip_template values containing ordinary Jinja are corrupted: for example, {{ inventory_hostname }} becomes the literal inventory_hostname, while {{ custom_id + 1 }} raises ValueError. The previous renderer left such expressions intact, so existing templates can now fail composition or silently produce incorrect names and addresses.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid — and it was worse than described: the same brace-swallowing exists in the TS reference this was ported from, so {{ inventory_hostname }} lost its braces on both sides, while {{ custom_id + 1 }} diverged (ValueError in Python vs "NaN" in TS).
Fixed as a shared-contract change rather than Python-only:
- new shared vector
05_unrelated_jinja_preserved.jsoncovering both cases (mixed{{ inventory_hostname }}-t{{ team_id }}and192.168.{{ bridge_base + team_id }}.{{ host_octet + 1 }}) - substitution now gated on the supported grammar (
\d+|team_id|bridge_basejoined by+ - *); anything else is returned verbatim - mirrored in deployer-ui
ac590b7ondevso TS/Python parity holds
Backend side: f17562f. Both suites green (394 pytest / 561 vitest), operators-and-codegen green.
Mirrors range42-deployer-ui ac590b7. Unrelated Ansible templates such as
{{ inventory_hostname }} or {{ custom_id + 1 }} were consumed by the
renderer — the latter raising ValueError where TS produced NaN. Gate the
substitution on the supported grammar; shared vector 05 covers it.
Cross-repo drift:
range42-deployer-uidevmoved the network-template contract, backend never followed. Any PR intodevcurrently failsschema-and-operators(first seen on #113).Changes
chore(schemas)— regenerateapp/schemas/generated.pyfrom the canonical schema; addsgateway_template,cidr,bridge,gatewaytoNode(deployer-uid90834a,7d05fb3). Fixes the codegen drift check.fix(overlay)— portexpand_replicationto the current operator contract (deployer-ui5594a4c,6818088), which the shared test vectors already assert:cidr_template/bridge_template/gateway_template) rather thanconfig.*, rendering to node-levelcidr/bridge/gateway{{ bridge_base + team_id }}supported alongside the legacy{140+team_id}formbridge_basetaken from the document root, defaulting to140when null or absentMirrors
src/overlay/expand_replication.tsline-for-line (same token regex, same left-to-right no-precedence eval) — the two implementations are contractually byte-parity.Verification
pytest -q— 394 passedgit diff --exit-code -- app/schemas/generated.pyclean after regeneration01–04inschema/test-vectors/expand_replication/all pass, including04_bridge_base_null_defaultsUnblocks #113 after a rebase.