Skip to content

Add per-command metadata propagation to interfaces - #3777

Open
jwalters2 wants to merge 2 commits into
OpenC3:mainfrom
jwalters2:command-extra-metadata
Open

Add per-command metadata propagation to interfaces#3777
jwalters2 wants to merge 2 commits into
OpenC3:mainfrom
jwalters2:command-extra-metadata

Conversation

@jwalters2

@jwalters2 jwalters2 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Replaces #3666, whose original head fork was deleted.

Problem

Command callers sometimes need to attach correlation and workflow metadata to a single command and make that metadata available to the interface that writes the packet. Previously, the cmd API did not provide a supported way to carry caller metadata through command topics, queues, and command retries.

Changes

  • Add an optional extra Hash/dict to the Ruby and Python cmd API families and scripting wrappers.
  • JSON-encode extra on the command topic and merge it into command.extra before the interface writes the packet.
  • Preserve metadata through command queues and hazardous-command retries.
  • Use the COSMOS JSON encoders for queued metadata so binary values and special numeric values follow the same serialization rules as command parameters.
  • Keep COSMOS-owned audit fields authoritative. Caller values cannot override cmd_string, username, interface_name, queue_username, or approver.
  • Accept both serialized metadata and the earlier raw-Hash queue representation when processing queued commands.
  • Document extra usage for Ruby and Python scripts.

Commands.build_cmd continues to clear template packet metadata. Caller metadata is applied only to the newly built command inside InterfaceMicroservice, preventing stale metadata from leaking between commands.

Compatibility

  • Existing callers are unchanged because extra is optional.
  • Commands without metadata retain their existing topic and queue behavior.
  • Queue processing remains compatible with entries created by the earlier implementation of this branch.

Testing

  • Ruby focused suite: 376 examples, 0 failures.
  • Python focused suite: 117 tests passed.
  • Coverage included the command APIs, scripting wrappers, interface microservices, queue model/processor, command topics, and preidentified protocol framing.
  • Verified queued binary metadata round-trips through the COSMOS JSON encoders.
  • Ran a Docker-based COSMOS Core end-to-end test using the PR images:
    • submitted a command through the JSON-RPC API with flow_uuid and hv_id metadata;
    • confirmed the interface completed the command write;
    • confirmed both raw and decomposed post-write command topics retained the metadata;
    • confirmed the emitted CCSDS command contained 8 packet bytes with APID 2;
    • confirmed caller-supplied queue_username and approver values were removed.
  • git diff --check, Ruby syntax checks, Python compilation, and the repository security/code-analysis checks passed.

@jwalters2
jwalters2 force-pushed the command-extra-metadata branch from 06f7730 to c30dd3f Compare August 27, 2026 05:09
@sonarqubecloud

Copy link
Copy Markdown

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