coveralls: ## Pull Request Test Coverage Report for [Build 613](https://coveralls.io/builds/23582325)

* **7** of **7**   **(100.0%)**  changed or added relevant lines in **1** file are covered.
* No unchanged relevant lines lost coverage.
* Overall coverage increased (+**0.005%**) to **96.496%**

---



|  Totals | [![Coverage Status](https://coveralls.io/builds/23582325/badge)](https://coveralls.io/builds/23582325) |
| :-- | --: |
| Change from base [Build 595](https://coveralls.io/builds/23330796): |  0.005% |
| Covered Lines: | 2919 |
| Relevant Lines: | 3025 |

---
##### 💛  - [Coveralls](https://coveralls.io)

diff --git a/WDL/Tree.py b/WDL/Tree.py
index a27ba2e..ad9f379 100644
--- a/WDL/Tree.py
+++ b/WDL/Tree.py
@@ -736,7 +736,7 @@ class Workflow(SourceNode):
             for decl in self.inputs:
                 ans = Env.bind(ans, [], decl.name, decl)
 
-        for elt in _decls_and_calls(self):
+        for elt in _decls_and_calls(self, exclude_outputs=True):
             if isinstance(elt, Decl):
                 if self.inputs is None:
                     ans = Env.bind(ans, [], elt.name, elt)
@@ -760,7 +760,7 @@ class Workflow(SourceNode):
                 if decl.expr is None and decl.type.optional is False:
                     ans = Env.bind(ans, [], decl.name, decl)
 
-        for elt in _decls_and_calls(self):
+        for elt in _decls_and_calls(self, exclude_outputs=True):
             if isinstance(elt, Decl):
                 if self.inputs is None and elt.expr is None and elt.type.optional is False:
                     ans = Env.bind(ans, [], elt.name, elt)
@@ -1060,11 +1060,15 @@ def load(
 
 
 def _decls_and_calls(
-    element: Union[Workflow, Scatter, Conditional]
+    element: Union[Workflow, Scatter, Conditional], exclude_outputs: bool = True
 ) -> Generator[Union[Decl, Call], None, None]:
     # Yield each Decl and Call in the workflow, including those nested within
     # scatter/conditional sections
-    for ch in element.children:
+    children = element.children
+    if isinstance(element, Workflow) and exclude_outputs:
+        children = element.inputs if element.inputs else []
+        children = children + element.elements
+    for ch in children:
         if isinstance(ch, (Decl, Call)):
             yield ch
         elif isinstance(ch, (Scatter, Conditional)):

available_inputs returns output Decls 
miniwdl version:  V0.1.7

For older workflows (ie draft 2/3) or really any workflow which does not define an `input { ... }` section, the `available_outputs` will return the `output` declarations as well as any input declarations.

For example, calling `available_outputs` on:
```wdl
workflow a {
   File in
   output {
      File out = in
   }
}
```
would yield both `in` and `out` as `inputs` to the workflow. Simply specifcying and input section for the workflow fixes this behaviour, however since alot of existing workflows do not have this section, we can expect a large number of workflows to exhibit this behaviour



diff --git a/tests/test_1doc.py b/tests/test_1doc.py
index 9087237..08310df 100644
--- a/tests/test_1doc.py
+++ b/tests/test_1doc.py
@@ -1279,6 +1279,22 @@ class TestDoc(unittest.TestCase):
         except WDL.Error.MultipleValidationErrors as multi:
             self.assertEqual(len(multi.exceptions), 2)
 
+    def test_issue135_workflow_available_inputs(self):
+        # Workflow.available_inputs should not include declarations in the
+        # output section
+        doc = r"""
+        workflow a {
+            File in
+            output {
+                File out = in
+            }
+        }
+        """
+        doc = WDL.parse_document(doc)
+        doc.typecheck()
+        self.assertEqual(len(doc.workflow.available_inputs), 1)
+        self.assertEqual(doc.workflow.available_inputs[0].name, "in")
+
 class TestCycleDetection(unittest.TestCase):
     def test_task(self):
         doc = r"""

pip install -e .
parse_log_pytest
requirements.txt
pytest pytest-cov pytest
apt-get update apt-get install -y gcc
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
coverage==7.8.0
exceptiongroup==1.2.2
iniconfig==2.1.0
lark-parser==0.7.1
-e git+https://github.com/chanzuckerberg/miniwdl.git@ab96c3a475b04779c314a30125780c48aad86a9d#egg=miniwdl
packaging==24.2
pluggy==1.5.0
pytest==8.3.5
pytest-cov==6.0.0
tomli==2.2.1

name: miniwdl
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - coverage==7.8.0
      - exceptiongroup==1.2.2
      - iniconfig==2.1.0
      - lark-parser==0.7.1
      - packaging==24.2
      - pluggy==1.5.0
      - pytest==8.3.5
      - pytest-cov==6.0.0
      - tomli==2.2.1
prefix: /opt/conda/envs/miniwdl

tests/test_1doc.py::TestDoc::test_issue135_workflow_available_inputs
tests/test_1doc.py::TestStruct::test_import
tests/test_1doc.py::TestTasks::test_compare_md5sums tests/test_1doc.py::TestTasks::test_errors tests/test_1doc.py::TestTasks::test_meta tests/test_1doc.py::TestTasks::test_placeholders tests/test_1doc.py::TestTasks::test_wc tests/test_1doc.py::TestTypes::test_invalid tests/test_1doc.py::TestTypes::test_parser tests/test_1doc.py::TestDoc::test_bam_chrom_counter tests/test_1doc.py::TestDoc::test_count_foo tests/test_1doc.py::TestDoc::test_draft2_workflow_outputs tests/test_1doc.py::TestDoc::test_errors tests/test_1doc.py::TestDoc::test_multi_errors tests/test_1doc.py::TestDoc::test_nested_scatter tests/test_1doc.py::TestDoc::test_scatter_conditional tests/test_1doc.py::TestDoc::test_task_forward_reference tests/test_1doc.py::TestDoc::test_workflow_inputs tests/test_1doc.py::TestCycleDetection::test_task tests/test_1doc.py::TestCycleDetection::test_workflow tests/test_1doc.py::TestStruct::test_decl tests/test_1doc.py::TestStruct::test_object_literal tests/test_1doc.py::TestStruct::test_parser
WDL/Tree.py
WDL/Tree.py