Skip to content

SY-4299: Strongly-Typed OPC UA Task Types - #2668

Open
emilbon99 wants to merge 19 commits into
sy-4299-strongly-type-ni-task-types-part-3from
sy-4299-opc-generated-types
Open

SY-4299: Strongly-Typed OPC UA Task Types#2668
emilbon99 wants to merge 19 commits into
sy-4299-strongly-type-ni-task-types-part-3from
sy-4299-opc-generated-types

Conversation

@emilbon99

@emilbon99 emilbon99 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Issue Pull Request

Linear Issue

SY-4299

Description

Moves the OPC UA integration onto Oracle-generated task config types, following the
NI pattern from Parts 1-3.

  • Schema: schemas/synnax/opc.oracle defines BaseChannel, InputChannel
    (channel, useAsIndex), OutputChannel (cmdChannel), ReadConfig
    (extends task.BaseReadConfig, adds device, arrayMode, arraySize), and
    WriteConfig (extends task.BaseWriteConfig). Generated clients land in Go, TS,
    Python, and C++ (client/*/opc, core/pkg/service/opc).
  • Console: feature/opc/task/types.ts parses only the generated schemas.
    Cross-field validation Oracle does not generate stays on the hand-composed deploy
    schemas: node-ID uniqueness, single index channel, array-mode size/rate coupling,
    stream-rate bounds, and command-channel uniqueness. Channel enablement follows the
    RFC 0043 polarity (disabled), threaded through the shared task components via the
    existing polarity prop.
  • Driver: InputChan/OutputChan hold the parsed generated structs
    (::synnax::opc::InputChannel/OutputChannel) and keep only runtime state
    (resolved NodeId, fetched Synnax channel) as hand-written code.
  • No legacy-key handling anywhere: configs stored with the old enabled polarity or
    the v0 write-channel channel key migrate once at Core boot (the storage cutover PR
    later in this chain).

⚠️ This PR is not independently deployable: a Core with old-shape stored configs needs
the boot migration from the storage cutover PR. The chain ships as one release.

Basic Readiness

  • I have performed a self-review of my code.
  • I have added relevant, automated tests to cover the changes.

Greptile Summary

This PR moves OPC UA task configuration onto Oracle-generated cross-language types and adopts disabled-polarity fields in the Console and driver.

  • Adds generated OPC task models for TypeScript, Python, C++, and Go.
  • Reworks Console schemas and cross-field deployment validation around generated types.
  • Updates OPC driver channel parsing and tests for the new wire shape.

Confidence Score: 4/5

The read-task parser should be fixed before merging because a schema-valid disabled channel with no Synnax binding prevents the entire task from configuring.

Generated input channels permit the default key 0, but the driver validates that key while constructing disabled channels and only filters those channels afterward.

Files Needing Attention: driver/opc/read_task.h

Important Files Changed

Filename Overview
schemas/synnax/opc.oracle Defines the shared OPC channel and read/write task contracts used for generation across four languages.
console/src/feature/opc/task/types.ts Replaces hand-composed base schemas with generated OPC schemas while retaining deployment-only cross-field validation.
driver/opc/read_task.h Adopts generated input-channel parsing but rejects unbound disabled channels before filtering them out.
driver/opc/write_task.h Adopts generated output-channel parsing and the new disabled polarity.
client/ts/src/opc/types.gen.ts Exposes generated Zod schemas and defaults consumed by the Console.
client/cpp/opc/json.gen.h Provides generated snake-case JSON parsing and serialization for OPC task configuration.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Schema["schemas/synnax/opc.oracle"] --> Oracle["Oracle code generation"]
  Oracle --> TS["TypeScript OPC schemas"]
  Oracle --> PY["Python OPC models"]
  Oracle --> CPP["C++ OPC models/parsers"]
  Oracle --> GO["Go OPC models"]
  TS --> Console["Console task form and deploy validation"]
  Console --> Config["Stored OPC task config"]
  Config --> Driver["OPC driver"]
  CPP --> Driver
  Driver --> OPCUA["OPC UA server"]
Loading

Reviews (1): Last reviewed commit: "Move the OPC UA integration onto the gen..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

Context used (4)

Author the OPC Oracle schema and rewire the Console task types and the
Driver channel structs onto the generated clients in all four languages.
Comment thread driver/opc/read_task.h
Comment on lines +63 to +64
if (this->synnax_key == 0)
parser.field_err("channel", "channel must be specified");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Disabled channels fail parsing

When a disabled input channel retains the generated default channel value of 0, InputChan rejects it before ReadTaskConfig filters disabled channels, causing the entire read task to fail configuration even when all enabled channels are valid.

Suggested change
if (this->synnax_key == 0)
parser.field_err("channel", "channel must be specified");
if (this->enabled && this->synnax_key == 0)
parser.field_err("channel", "channel must be specified");

Knowledge Base Used:

…pes-part-3' into sy-4299-opc-generated-types
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.75000% with 10 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (sy-4299-strongly-type-ni-task-types-part-3@ae2a8ad). Learn more about missing BASE report.

Files with missing lines Patch % Lines
oracle/plugin/cpp/json/json.go 66.66% 2 Missing and 2 partials ⚠️
oracle/plugin/cpp/types/types.go 69.23% 2 Missing and 2 partials ⚠️
client/ts/src/opc/types.gen.ts 71.42% 2 Missing ⚠️

❌ Your patch check has failed because the patch coverage (68.75%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@                              Coverage Diff                              @@
##             sy-4299-strongly-type-ni-task-types-part-3    #2668   +/-   ##
=============================================================================
  Coverage                                              ?   76.19%           
=============================================================================
  Files                                                 ?     2875           
  Lines                                                 ?   144619           
  Branches                                              ?    10218           
=============================================================================
  Hits                                                  ?   110198           
  Misses                                                ?    28478           
  Partials                                              ?     5943           
Flag Coverage Δ
client-ts 87.97% <71.42%> (?)
core 73.53% <ø> (?)
oracle 65.13% <68.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…pes-part-3' into sy-4299-opc-generated-types
…pes-part-3' into sy-4299-opc-generated-types
…pes-part-3' into sy-4299-opc-generated-types
…pes-part-3' into sy-4299-opc-generated-types
…pes-part-3' into sy-4299-opc-generated-types
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