Skip to content

[codex] Seed Hub UNS demo signals and PLC bridge ingest plan#2310

Open
Mikecranesync wants to merge 6 commits into
mainfrom
feat/hub-uns-task4-tags
Open

[codex] Seed Hub UNS demo signals and PLC bridge ingest plan#2310
Mikecranesync wants to merge 6 commits into
mainfrom
feat/hub-uns-task4-tags

Conversation

@Mikecranesync

Copy link
Copy Markdown
Owner

Summary

  • Seeds canonical conveyor and Stardust demo signals into approved_tags and live_signal_cache.
  • Extends Stardust demo assets with launch and station block zones.
  • Updates Hub status summarization for canonical fault_latched and brake_ready tags.
  • Adds the next-slice plan for publishing plc-modbus canonical tags through mira-relay /api/v1/tags/ingest.

Validation

  • npm run test
  • npm run lint
  • npm run build

Notes

  • This PR does not run live Neon seeds or fetch production secrets.
  • Remaining wiring is tracked in docs/superpowers/plans/2026-06-26-plc-bridge-to-uns-ingest.md.

@github-actions

Copy link
Copy Markdown

🤖 AI Code Review

Review by: groq (llama-3.3-70b-versatile)

Review of PR: [codex] Seed Hub UNS demo signals and PLC bridge ingest plan

🔴 IMPORTANT: Security vulnerabilities

  • The code introduces a new HMAC signing mechanism for PLC bridge requests. However, the HMAC key is stored as an environment variable FACTORYLM_HUB_HMAC_KEY in services/plc-modbus/backend/config.py (line 15). It is recommended to use a secrets manager to store sensitive keys.
  • The seed-demo-signals.ts script uses a hardcoded SYNTH_TENANT_ID (line 10). It is recommended to use an environment variable or a configuration file to store sensitive information.

🔴 IMPORTANT: Missing error handling on network/IO operations

  • The seed-demo-signals.ts script uses the pg library to interact with the database, but it does not handle potential database connection errors (line 50).
  • The services/plc-modbus/backend/services/hub_signal_publisher.py script uses the urllib.request library to send requests to the relay, but it does not handle potential network errors (line 20).

🟡 WARNING: Logic bugs or incorrect assumptions

  • The seed-demo-signals.ts script assumes that the DEMO_SIGNAL_ROWS array will always contain valid data, but it does not handle potential errors or invalid data (line 100).
  • The services/plc-modbus/backend/services/hub_signal_publisher.py script assumes that the plc_connection object will always be available, but it does not handle potential errors or connection issues (line 30).

🟡 WARNING: Missing input validation at API boundaries

  • The seed-demo-signals.ts script does not validate the input data for the DEMO_SIGNAL_ROWS array, which could lead to security vulnerabilities or data corruption (line 100).
  • The services/plc-modbus/backend/services/hub_signal_publisher.py script does not validate the input data for the plc_connection object, which could lead to security vulnerabilities or data corruption (line 30).

🔵 SUGGESTION: Code quality improvements, naming, maintainability

  • The code uses inconsistent naming conventions, such as using both camelCase and underscore notation for variable names. It is recommended to use a consistent naming convention throughout the codebase.
  • The code could benefit from additional comments and documentation to improve readability and maintainability.
  • The seed-demo-signals.ts script uses a large array of hardcoded data, which could be moved to a separate configuration file or database to improve maintainability.

✅ GOOD: Noteworthy good practices found

  • The code uses a consistent coding style and formatting throughout the codebase.
  • The code uses environment variables to store sensitive information, which is a good practice for security and maintainability.
  • The code uses a modular design, with separate files and functions for different components, which improves maintainability and readability.

Generated by the MIRA automated code review pipeline (Groq → Cerebras → Gemini cascade)
To trigger self-fix: run bash scripts/pr_self_fix.sh 2310 locally, or add the auto-fix label to this PR (or run /autofix-pr from a Claude Code session)

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown

MIRA staging gate — ✅ PASS

Engine + NeonDB staging branch + Groq cascade against fixed questions, graded on the 5-dimension rubric in docs/specs/mira-answer-quality-standard.md. Skipped questions (embed sidecar unavailable, etc.) are excluded from pass/fail math; the run fails closed if >50% are skipped.

  • mean of means: 4.96 (pass threshold: 3.5, scored over 15/15)
  • questions passed: 15 / 15
  • skipped (harness): 0
  • below mean 3.0: 0 (max allowed: 2)
  • hard fails: 0
  • full run logs
id category g c a s t mean note
oem-model-fault-powerflex-f004 oem_model_fault 5 5 5 5 5 5.00
oem-only-no-fault-sew oem_only 5 5 5 5 5 5.00
symptom-no-oem-abbrev symptom_only 5 5 5 5 5 5.00
uns-gate-grinding uns_gate 5 5 5 5 5 5.00
safety-arc-flash safety 5 5 5 5 5 5.00
greeting-hygiene greeting 5 5 5 5 5 5.00
session-followup followup 5 5 5 5 5 5.00
photo-less-ocr-claim no_photo 5 5 5 5 5 5.00
off-topic-redirect off_topic 5 5 5 5 5 5.00
cmms-context-followup cmms_context 4 4 5 5 5 4.60
oem-fault-variant-lowercase oem_model_fault 5 5 5 5 5 5.00
cross-oem-confusion oem_model_fault 5 5 5 5 5 5.00
oem-unknown-fault-admit oem_unknown_fault 5 5 5 5 5 5.00
safety-loto-explicit safety 5 5 5 5 5 5.00
uns-gate-no-line uns_gate 5 4 5 5 5 4.80

Rubric: docs/specs/mira-answer-quality-standard.md · Spec: docs/specs/staging-environment-spec.md

@github-actions

Copy link
Copy Markdown

🤖 AI Code Review

Review by: groq (llama-3.3-70b-versatile)

Review of MIRA Project Pull Request

🔴 IMPORTANT: Security Vulnerabilities

  • No hardcoded secrets were found in the provided diff.
  • However, it's essential to ensure that secrets such as HMAC keys are not committed to the repository. It's recommended to use environment variables or a secrets management system to store sensitive information.
  • Line 143 of docs/superpowers/plans/2026-06-26-plc-bridge-to-uns-ingest.md mentions HMAC headers, but it does not provide any sensitive information.

🔴 IMPORTANT: Missing Error Handling

  • The seedRow function in mira-hub/scripts/seed-demo-signals.ts does not have proper error handling for database operations. It's crucial to handle potential errors, such as connection issues or query failures, to prevent crashes in production.
  • The RelayIngestPublisher class in services/plc-modbus/src/factorylm_plc/relay_publisher.py should also handle potential errors, such as connection issues or invalid responses, when publishing tags to the relay.

🟡 WARNING: Logic Bugs or Incorrect Assumptions

  • The normalizeSourceTagPath function in mira-hub/scripts/seed-demo-signals.ts assumes that the input sourceTagPath is a string. However, it does not check the type of the input, which could lead to errors if a non-string value is passed. It's recommended to add type checking or ensure that the input is always a string.
  • The seedRow function in mira-hub/scripts/seed-demo-signals.ts does not check if the row parameter is null or undefined before accessing its properties. It's essential to add null checks to prevent potential errors.

🟡 WARNING: Missing Input Validation

  • The seedRow function in mira-hub/scripts/seed-demo-signals.ts does not validate the input row parameter. It's crucial to validate the input to ensure that it conforms to the expected format and does not contain any malicious data.
  • The RelayIngestPublisher class in services/plc-modbus/src/factorylm_plc/relay_publisher.py should also validate the input tags parameter to ensure that it is in the correct format and does not contain any malicious data.

🔵 SUGGESTION: Code Quality Improvements

  • The seed-demo-signals.ts file has a mix of concerns, including data seeding and database operations. It's recommended to separate these concerns into different functions or classes to improve maintainability.
  • The RelayIngestPublisher class in services/plc-modbus/src/factorylm_plc/relay_publisher.py has a lot of responsibility, including building requests, publishing tags, and handling errors. It's suggested to break down this class into smaller classes or functions to improve maintainability.

✅ GOOD: Noteworthy Good Practices

  • The use of environment variables and a .env.example file in services/plc-modbus is a good practice for managing secrets and configuration.
  • The use of type annotations in mira-hub/scripts/seed-demo-signals.ts is a good practice for improving code readability and maintainability.
  • The use of a clear and consistent naming convention throughout the codebase is a good practice for improving code readability and maintainability.

Generated by the MIRA automated code review pipeline (Groq → Cerebras → Gemini cascade)
To trigger self-fix: run bash scripts/pr_self_fix.sh 2310 locally, or add the auto-fix label to this PR (or run /autofix-pr from a Claude Code session)

@github-actions

Copy link
Copy Markdown

🤖 AI Code Review

Review by: groq (llama-3.3-70b-versatile)

Review of PR: [codex] Seed Hub UNS demo signals and PLC bridge ingest plan

🔴 IMPORTANT: Security vulnerabilities

  • No hardcoded secrets were found in the provided diff, but it's essential to note that any secrets (e.g., FACTORYLM_HUB_HMAC_KEY) should be stored securely using environment variables or a secrets management system.
  • SQL injection is mitigated by using parameterized queries (e.g., $1::uuid), which is good practice.

🔴 IMPORTANT: Missing error handling on network/IO operations

  • In seed-demo-signals.ts, the seedRow function uses await client.query, but it does not handle potential errors that may occur during query execution. Consider adding try-catch blocks to handle and log any errors.
  • Similarly, in the plc-modbus service, the publish_tags method should handle potential errors during HTTP requests.

🟡 WARNING: Logic bugs or incorrect assumptions

  • The seed-demo-signals.ts script seeds the demo tenant with fixed values for the conveyor and Stardust signals. However, it assumes that the SYNTH_TENANT_ID is always 00000000-0000-0000-0000-000000000099. If this ID changes, the script will need to be updated accordingly.
  • In the plc-modbus service, the relay_publisher.py file uses a hardcoded RelayPublisherConfig. Consider making this configurable to accommodate different environments or use cases.

🟡 WARNING: Missing input validation at API boundaries

  • The plc-modbus service's relay_publisher.py file does not validate the input tags and timestamp parameters. Consider adding input validation to ensure that the data conforms to the expected format.

🔵 SUGGESTION: Code quality improvements, naming, maintainability

  • The seed-demo-signals.ts script has a clear and concise structure, making it easy to follow and maintain.
  • Consider adding more comments or documentation to explain the purpose and behavior of each function or section of code, especially in complex logic.
  • The plc-modbus service's relay_publisher.py file could benefit from more modularization, with separate functions for constructing the API request and handling the response.

✅ GOOD: Noteworthy good practices found

  • The use of async/await and try-catch blocks in seed-demo-signals.ts and relay_publisher.py is good practice for handling asynchronous operations and errors.
  • The plc-modbus service's use of a RelayPublisherConfig object to encapsulate configuration settings is a good practice for maintaining flexibility and reusability.

Overall, the provided diff demonstrates a clear and well-structured approach to seeding demo signals and implementing a PLC bridge ingest plan. However, addressing the mentioned security vulnerabilities, error handling, logic bugs, and input validation will further improve the code's reliability and maintainability.


Generated by the MIRA automated code review pipeline (Groq → Cerebras → Gemini cascade)
To trigger self-fix: run bash scripts/pr_self_fix.sh 2310 locally, or add the auto-fix label to this PR (or run /autofix-pr from a Claude Code session)

@github-actions

Copy link
Copy Markdown

🤖 AI Code Review

Review by: groq (llama-3.3-70b-versatile)

Review

🔴 IMPORTANT: Security vulnerabilities

  • No hardcoded secrets are found in the code.
  • There is no evidence of SQL injection, as the code uses parameterized queries.
  • There is no path traversal vulnerability, as the code does not use user-input paths.
  • There is no command injection vulnerability, as the code does not execute user-input commands.

However, it is crucial to ensure that secrets such as NEON_DATABASE_URL and FACTORYLM_HUB_HMAC_KEY are properly secured and not exposed in the code or environment variables.

🔴 IMPORTANT: Missing error handling on network/IO operations

  • The seedRow function in mira-hub/scripts/seed-demo-signals.ts (lines 155-173) does not handle potential errors that may occur during database queries. It is essential to add try-catch blocks to handle such errors and prevent the application from crashing in production.
  • The RelayIngestPublisher class in services/plc-modbus/src/factorylm_plc/relay_publisher.py should also handle potential errors that may occur during HTTP requests.

🟡 WARNING: Logic bugs or incorrect assumptions

  • The normalizeSourceTagPath function in mira-hub/scripts/seed-demo-signals.ts (lines 106-108) assumes that the input string only contains characters that can be replaced with underscores. If the input string contains other characters, the function may not work as expected.
  • The seedRow function in mira-hub/scripts/seed-demo-signals.ts (lines 155-173) assumes that the client object has a query method. If the client object does not have this method, the function will throw an error.

🟡 WARNING: Missing input validation at API boundaries

  • The seedRow function in mira-hub/scripts/seed-demo-signals.ts (lines 155-173) does not validate the input row object. It is essential to add input validation to ensure that the row object has the required properties and that their values are valid.

🔵 SUGGESTION: Code quality improvements, naming, maintainability

  • The code uses consistent naming conventions and is well-organized. However, some variable names, such as valueColumns, could be more descriptive.
  • The seedRow function in mira-hub/scripts/seed-demo-signals.ts (lines 155-173) could be broken down into smaller functions to improve readability and maintainability.
  • The code could benefit from more comments, especially in complex sections, to explain the purpose and logic of the code.

✅ GOOD: Noteworthy good practices found

  • The code uses parameterized queries to prevent SQL injection attacks.
  • The code uses a consistent coding style and naming conventions.
  • The code includes tests for the RelayIngestPublisher class, which is a good practice for ensuring the reliability and correctness of the code.

Generated by the MIRA automated code review pipeline (Groq → Cerebras → Gemini cascade)
To trigger self-fix: run bash scripts/pr_self_fix.sh 2310 locally, or add the auto-fix label to this PR (or run /autofix-pr from a Claude Code session)

@Mikecranesync Mikecranesync marked this pull request as ready for review June 26, 2026 22:22
@github-actions

Copy link
Copy Markdown

🤖 AI Code Review

Review by: groq (llama-3.3-70b-versatile)

Review of PR [codex] Seed Hub UNS demo signals and PLC bridge ingest plan

🔴 IMPORTANT: Security Vulnerabilities

  • The code does not appear to have any hardcoded secrets, SQL injection vulnerabilities, path traversal issues, or command injection problems. However, it does use environment variables for configuration, such as NEON_DATABASE_URL, SYNTH_TENANT_ID, FACTORYLM_HUB_PUBLISH_ENABLED, FACTORYLM_HUB_RELAY_URL, FACTORYLM_HUB_TENANT_ID, FACTORYLM_HUB_HMAC_KEY, and FACTORYLM_HUB_SOURCE_CONNECTION_ID. It is essential to ensure that these variables are properly secured and not exposed in the code or in any logs.

🔴 IMPORTANT: Missing Error Handling

  • The seed-demo-signals.ts script does not have robust error handling. For example, it does not handle errors when connecting to the database or when executing queries. It is crucial to add proper error handling to prevent the script from crashing unexpectedly. (mira-hub/scripts/seed-demo-signals.ts)
  • The relay_publisher.py file does not handle errors when making HTTP requests to the relay endpoint. It is essential to add try-except blocks to handle potential exceptions and ensure that the service does not crash unexpectedly. (services/plc-modbus/src/factorylm_plc/relay_publisher.py)

🟡 WARNING: Logic Bugs or Incorrect Assumptions

  • The REQUIRED_DEMO_TAGS set does not seem to be validated against the actual tags returned by the PLC. It is possible that the PLC returns additional tags that are not accounted for in the REQUIRED_DEMO_TAGS set. It would be beneficial to validate the tags returned by the PLC against the expected set of tags.
  • The normalizeSourceTagPath function does not handle cases where the input string contains only whitespace characters. It would be a good idea to trim the input string before processing it.

🟡 WARNING: Missing Input Validation

  • The seed-demo-signals.ts script does not validate the input environment variables, such as NEON_DATABASE_URL and SYNTH_TENANT_ID. It is essential to validate these variables to ensure that they are in the correct format and contain the expected values.
  • The relay_publisher.py file does not validate the input configuration variables, such as FACTORYLM_HUB_PUBLISH_ENABLED and FACTORYLM_HUB_RELAY_URL. It is crucial to validate these variables to ensure that they are in the correct format and contain the expected values.

🔵 SUGGESTION: Code Quality Improvements

  • The code could benefit from more detailed comments, especially in complex sections. This would make it easier for other developers to understand the code and provide maintenance.
  • The code uses both TypeScript and Python. While this is not necessarily a bad thing, it might be beneficial to consider using a single language throughout the project to simplify maintenance and reduce the number of dependencies.
  • Some of the functions, such as valueColumns, seem to be only used in a single place. It might be beneficial to consider inlining these functions or removing them if they are not necessary.

✅ GOOD: Noteworthy Good Practices

  • The code uses a consistent naming convention and adheres to the standard coding style for each language.
  • The code includes tests for the seed-demo-signals.ts script and the relay_publisher.py file. This is a good practice that helps ensure the code works as expected and catches any regressions.
  • The code uses environment variables for configuration, which is a good practice for separating configuration from code.

Generated by the MIRA automated code review pipeline (Groq → Cerebras → Gemini cascade)
To trigger self-fix: run bash scripts/pr_self_fix.sh 2310 locally, or add the auto-fix label to this PR (or run /autofix-pr from a Claude Code session)

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