Skip to content

refactor(workflow): replace env-var stage handoff with workflow context#186

Open
liamnwhite1 wants to merge 11 commits into
mainfrom
refactor/125-workflow-context-stage-handoff
Open

refactor(workflow): replace env-var stage handoff with workflow context#186
liamnwhite1 wants to merge 11 commits into
mainfrom
refactor/125-workflow-context-stage-handoff

Conversation

@liamnwhite1

Copy link
Copy Markdown
Collaborator

Summary

Replace workflow-stage communication through mutable MYNA_* environment variables with explicit WorkflowContext propagation, then document the architecture decision and add harness guardrails for future docs-sensitive changes.

Related issues

Details

This refactor adds WorkflowContext to carry the input file, current step, previous step, step class, and step index through workflow execution. myna run and myna sync now pass workflow state directly into component stages, and stage execution runs in-process while preserving CLI argument behavior by temporarily patching sys.argv.

Affected apps, databases, and metadata helpers now read workflow state through context-backed accessors or app instance attributes instead of directly depending on mutable environment variables. Legacy environment-variable fallback remains in place for direct script invocation.

The PR also updates architecture and developer documentation, adds an ADR for the workflow context decision, expands application documentation, and strengthens the docs harness so future PRs consider architecture documentation and complete the repository PR template.

Impact

Behavioral impact is medium because workflow stage execution and state propagation are changed across core workflow, component, app, and database paths. Risk is mitigated by preserving direct-invocation fallback behavior and adding regression coverage for context propagation, stage argument forwarding, and avoiding workflow environment mutation.

Maintainability improves by making workflow state explicit, testable, and less dependent on process-global environment state.

Testing strategy

Validated with:

  • uv run pytest
  • python3 scripts/check_docs_harness.py
  • uv run python scripts/check_docs_harness.py
  • python3 -m py_compile scripts/check_docs_harness.py
  • git diff --check

The full test run reported 55 passed, 1 skipped, and 11 deselected.

Checklist

  • Architecture/docs impact considered. Updated ARCHITECTURE.md, developer docs, and/or ADRs where needed, or explained why not.

@liamnwhite1 liamnwhite1 force-pushed the refactor/125-workflow-context-stage-handoff branch from 46e8c4b to 2696c7f Compare June 2, 2026 11:32

@gknapp1 gknapp1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

First pass through reading the code, this seems like a reasonable approach. That said, I do need to spend some more time reading through it in detail and testing functionality before approving.

Comment thread docs/decisions/0001-workflow-context.md Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This further reinforces my experience from #185 on the decisions file. The important parts of this decision are included in changes to ARCHITECTURE.md, so I'm not seeing a strong benefit for this more verbose file. @liamnwhite1 is there a reason to keep this that I'm missing?

That said, some of this rationale could be in the PR description to assist reviewer(s).

Base automatically changed from docs/180-add-repo-agent-harness to main June 19, 2026 20:02
liamnwhite1 and others added 6 commits June 22, 2026 14:31
Remove the workflow-step communication that previously relied on mutable
MYNA_* environment variables between Myna workflow stages.

Changes:
- add explicit `WorkflowContext` support for input file, current step,
  previous step, step class, and step index
- update `MynaApp` to consume explicit workflow context first while preserving
  legacy environment-variable fallback for direct script invocation
- run component configure/execute/postprocess stages in-process instead of
  launching Python wrapper subprocesses
- preserve stage CLI argument behavior by temporarily patching `sys.argv`
  during in-process stage calls
- update `myna run` and `myna sync` to pass workflow state directly to
  components instead of mutating `MYNA_*` variables
- replace affected app/database direct env reads with context-backed accessors
  or app instance attributes
- add regression tests for context propagation, stage argument forwarding, and
  absence of workflow env mutation

Closes #125

Verification:
- `uv run pytest`
- 55 passed, 1 skipped, 11 deselected
Document the workflow context architecture and application guidance in the current root-docs layout.

Extend the docs harness to require architecture documentation for sensitive changes and enforce PR template guidance/headings.

Co-authored-by: White, Liam <whiteln@ornl.gov>
@gknapp1 gknapp1 force-pushed the refactor/125-workflow-context-stage-handoff branch from 2696c7f to e163152 Compare July 1, 2026 14:51
@gknapp1 gknapp1 requested a review from MattRolchigo as a code owner July 1, 2026 15:58
gknapp1 added 2 commits July 2, 2026 11:09
- fixes error in input file with meshing settings
- adds flexibility in solidification data concatenation from additivefoam to handle headers (different versions of additivefoam have different behaviors with outputting headers for decomposed ExacA files)
- forgot to remove old code for solidification data reconstruction, so caused conflict
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.

2 participants