Skip to content

fix(overlay): restore TS/Python parity for node-level network templates - #114

Open
pparage wants to merge 3 commits into
devfrom
fix/overlay-network-template-parity
Open

fix(overlay): restore TS/Python parity for node-level network templates#114
pparage wants to merge 3 commits into
devfrom
fix/overlay-network-template-parity

Conversation

@pparage

@pparage pparage commented Aug 4, 2026

Copy link
Copy Markdown
Member

Cross-repo drift: range42-deployer-ui dev moved the network-template contract, backend never followed. Any PR into dev currently fails schema-and-operators (first seen on #113).

Changes

  • chore(schemas) — regenerate app/schemas/generated.py from the canonical schema; adds gateway_template, cidr, bridge, gateway to Node (deployer-ui d90834a, 7d05fb3). Fixes the codegen drift check.
  • fix(overlay) — port expand_replication to the current operator contract (deployer-ui 5594a4c, 6818088), which the shared test vectors already assert:
    • network templates read from node level (cidr_template / bridge_template / gateway_template) rather than config.*, rendering to node-level cidr / bridge / gateway
    • canonical Jinja form {{ bridge_base + team_id }} supported alongside the legacy {140+team_id} form
    • bridge_base taken from the document root, defaulting to 140 when null or absent

Mirrors src/overlay/expand_replication.ts line-for-line (same token regex, same left-to-right no-precedence eval) — the two implementations are contractually byte-parity.

Verification

  • pytest -q — 394 passed
  • git diff --exit-code -- app/schemas/generated.py clean after regeneration
  • vectors 0104 in schema/test-vectors/expand_replication/ all pass, including 04_bridge_base_null_defaults

Unblocks #113 after a rebase.

pparage added 2 commits August 4, 2026 11:15
…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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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*\}\}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.json covering both cases (mixed {{ inventory_hostname }}-t{{ team_id }} and 192.168.{{ bridge_base + team_id }}.{{ host_octet + 1 }})
  • substitution now gated on the supported grammar (\d+|team_id|bridge_base joined by + - *); anything else is returned verbatim
  • mirrored in deployer-ui ac590b7 on dev so 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant