Skip to content

Commit 66b1b20

Browse files
ctruedenclaude
andcommitted
scijava-execute: run things that declare their inputs and outputs
Phase 3 begins. @parameter on fields, a MemberParser that reads them (inherited ones included), and Executables.run, which binds inputs by name and hands back outputs by name -- SciJava Common's module layer, rebuilt on scijava-struct. @parameter here means only what it meant in SciJava Common's module sense: an input or output of something runnable. Injecting a service is @dependency, in scijava-context. Conflating the two is what made the original annotation confusing. Cancellation needed nothing of its own, as the design predicted: a run is a Callable for an executor, and cancelling the Future interrupts it. The test cancels a sleeping task and checks it did not reach the end. Two bugs the tests caught: - FieldParameterMember inherited Member's read-only createInstance, so every input binding threw UnsupportedOperationException. It must return a ValueAccessibleMemberInstance to be writable. - The required-input check tested whether the field was null, which silently passes for primitives: a missing required double would have run as 0.0 and produced a wrong answer rather than an error. A required input must now be supplied, not merely non-null. On lifting the member parsers out of ops-engine, which the plan called for: inspecting ops.engine.struct, only about five of nineteen classes are framework-neutral. The parsers reach into Op-specific exceptions, Op-specific annotations (@nullable and @OpDependency, in the already released scijava-ops-spi) and ops.engine.util helpers, so lifting them means first deciding where an optional-parameter annotation lives and then changing a released module. Better to build this layer first and let a second real consumer show what is genuinely shared. The plan records the specific couplings. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013gJpzGd3ksbME4CN6Tu2ni
1 parent daeb317 commit 66b1b20

9 files changed

Lines changed: 871 additions & 11 deletions

File tree

‎docs/migration-plan.md‎

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -609,17 +609,39 @@ No application context required by anything in this phase.
609609

610610
### Phase 3 — Execution layer
611611

612-
- **Factor the framework-neutral member parsing out of `scijava-ops-engine`**
613-
into `scijava-struct` (or a `scijava-struct-reflect` beside it):
614-
`ClassParameterMemberParser`, `Field`/`MethodParameterMemberParser`,
615-
`FunctionalParameters`, `SynthesizedParameterMember`. The Op-specific pieces
616-
(`OpDependency` members, retyping/resizing) stay in `ops-engine`. The
617-
execution layer must **not** depend on `ops-engine`; if a dependency is
618-
useful it runs the other way, `ops-engine` → execution layer.
619-
- **Execution module** (name TBD): pre/postprocessor chains, input resolution,
620-
a `@Parameter` equivalent, and a runner — built on `scijava-struct`.
621-
Cancellation needs nothing here: the runner hands back a `Future`, and
622-
cancelling it interrupts the worker.
612+
- **Factoring the member parsing out of `scijava-ops-engine`** is wanted, but
613+
the coupling is deeper than the file names suggest. Inspecting the nineteen
614+
classes in `ops.engine.struct`, only a handful are framework-neutral
615+
(`FieldInstance`, `ParameterData`, `FunctionalMethodType`,
616+
`SynthesizedParameterMember`, `RetypingRequest`). The parsers themselves
617+
reach into Op-specific exceptions (`FunctionalTypeOpException`,
618+
`NullablesOnMultipleMethodsException`), Op-specific annotations
619+
(`@Nullable`, `@OpDependency` in `scijava-ops-spi`), and `ops.engine.util`
620+
helpers. Lifting them means first deciding where an "optional parameter"
621+
annotation lives, and `scijava-ops-spi` is already released.
622+
- So: build the execution layer first and let a **second real consumer**
623+
show which abstractions are genuinely shared, rather than guessing from
624+
the Ops side alone. That is the same discipline applied to `ObjectService`
625+
and the settings store.
626+
- The execution layer must **not** depend on `ops-engine`; if a dependency
627+
is useful it runs the other way.
628+
- **`scijava-execute`** (`org.scijava.execute`): pre/postprocessor chains,
629+
input resolution, a `@Parameter` equivalent, and a runner — built on
630+
`scijava-struct`. Cancellation needs nothing of its own: a run is a
631+
`Callable` for an executor, and cancelling the `Future` interrupts it.
632+
- **Started**: `@Parameter` on fields, a `MemberParser` that reads them
633+
(inherited ones included), and `Executables.run`, which binds inputs by
634+
name and returns outputs by name.
635+
- `@Parameter` here means only what it meant in SciJava Common's *module*
636+
sense — an input or output of something runnable. Injecting a service is
637+
`@Dependency`, in `scijava-context`. Conflating those two is what made the
638+
original confusing.
639+
- **A required input must be supplied, not merely non-null.** Checking the
640+
field instead would let a missing required `double` run silently as `0.0`,
641+
since a primitive field is never null.
642+
- Still to do here: the pre/postprocessor chain, and factoring the
643+
framework-neutral member parsing out of `ops-engine` — which is a larger
644+
job than it looks, see below.
623645
- **Commands:** a struct, plus menu metadata, plus `run`. Commands and Ops
624646
remain separate concepts sharing this layer.
625647
- **Scripting:** `javax.script` is not general enough. GraalVM's Truffle

‎pom.xml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
<module>scijava-discovery</module>
6767
<module>scijava-discovery-test</module>
6868
<module>scijava-events</module>
69+
<module>scijava-execute</module>
6970
<module>scijava-function</module>
7071
<module>scijava-index</module>
7172
<module>scijava-io3</module>

‎scijava-execute/pom.xml‎

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<parent>
6+
<groupId>org.scijava</groupId>
7+
<artifactId>pom-scijava</artifactId>
8+
<version>44.0.0</version>
9+
<relativePath />
10+
</parent>
11+
12+
<artifactId>scijava-execute</artifactId>
13+
<version>1.0.0-SNAPSHOT</version>
14+
15+
<name>SciJava Execute</name>
16+
<description>Running things that declare their inputs and outputs.</description>
17+
<url>https://github.com/scijava/scijava</url>
18+
<inceptionYear>2026</inceptionYear>
19+
<organization>
20+
<name>SciJava</name>
21+
<url>https://scijava.org/</url>
22+
</organization>
23+
<licenses>
24+
<license>
25+
<name>Simplified BSD License</name>
26+
<distribution>repo</distribution>
27+
</license>
28+
</licenses>
29+
30+
<developers>
31+
<developer>
32+
<id>ctrueden</id>
33+
<name>Curtis Rueden</name>
34+
<roles>
35+
<role>founder</role>
36+
<role>lead</role>
37+
<role>reviewer</role>
38+
<role>support</role>
39+
<role>maintainer</role>
40+
</roles>
41+
</developer>
42+
<developer>
43+
<id>gselzer</id>
44+
<name>Gabriel Selzer</name>
45+
<roles>
46+
<role>founder</role>
47+
<role>debugger</role>
48+
<role>reviewer</role>
49+
<role>support</role>
50+
</roles>
51+
</developer>
52+
</developers>
53+
<contributors>
54+
<contributor>
55+
<name>Johannes Schindelin</name>
56+
<properties><id>dscho</id></properties>
57+
</contributor>
58+
</contributors>
59+
60+
<mailingLists>
61+
<mailingList>
62+
<name>Image.sc Forum</name>
63+
<archive>https://forum.image.sc/tag/scijava</archive>
64+
</mailingList>
65+
</mailingLists>
66+
67+
<scm>
68+
<connection>scm:git:https://github.com/scijava/scijava</connection>
69+
<developerConnection>scm:git:git@github.com:scijava/scijava</developerConnection>
70+
<tag>HEAD</tag>
71+
<url>https://github.com/scijava/scijava</url>
72+
</scm>
73+
<issueManagement>
74+
<system>GitHub Issues</system>
75+
<url>https://github.com/scijava/scijava/issues</url>
76+
</issueManagement>
77+
<ciManagement>
78+
<system>GitHub Actions</system>
79+
<url>https://github.com/scijava/scijava/actions</url>
80+
</ciManagement>
81+
82+
<properties>
83+
<package-name>org.scijava.execute</package-name>
84+
85+
<license.licenseName>bsd_2</license.licenseName>
86+
<license.copyrightOwners>SciJava developers.</license.copyrightOwners>
87+
88+
<!-- Note: These versions must match across all component POMs! -->
89+
<scijava-common3.version>1.0.1-SNAPSHOT</scijava-common3.version>
90+
<scijava-struct.version>1.0.1-SNAPSHOT</scijava-struct.version>
91+
</properties>
92+
93+
<dependencies>
94+
<dependency>
95+
<groupId>org.scijava</groupId>
96+
<artifactId>scijava-common3</artifactId>
97+
<version>${scijava-common3.version}</version>
98+
</dependency>
99+
<dependency>
100+
<groupId>org.scijava</groupId>
101+
<artifactId>scijava-struct</artifactId>
102+
<version>${scijava-struct.version}</version>
103+
</dependency>
104+
105+
<!-- Test scope dependencies -->
106+
<dependency>
107+
<groupId>org.junit.jupiter</groupId>
108+
<artifactId>junit-jupiter-api</artifactId>
109+
<scope>test</scope>
110+
</dependency>
111+
</dependencies>
112+
113+
<build>
114+
<plugins>
115+
<plugin>
116+
<artifactId>maven-enforcer-plugin</artifactId>
117+
<executions>
118+
<execution>
119+
<id>enforce-package-rules</id>
120+
<goals>
121+
<goal>enforce</goal>
122+
</goals>
123+
<phase>test</phase>
124+
<configuration>
125+
<rules>
126+
<NoPackageCyclesRule implementation="org.scijava.maven.plugin.enforcer.NoPackageCyclesRule" />
127+
<NoSubpackageDependenceRule implementation="org.scijava.maven.plugin.enforcer.NoSubpackageDependenceRule" />
128+
</rules>
129+
</configuration>
130+
</execution>
131+
</executions>
132+
</plugin>
133+
<plugin>
134+
<artifactId>maven-javadoc-plugin</artifactId>
135+
<configuration>
136+
<links>
137+
<link>https://javadoc.scijava.org/Java11/</link>
138+
</links>
139+
</configuration>
140+
</plugin>
141+
</plugins>
142+
</build>
143+
</project>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* #%L
3+
* Running things that declare their inputs and outputs.
4+
* %%
5+
* Copyright (C) 2026 SciJava developers.
6+
* %%
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
*
10+
* 1. Redistributions of source code must retain the above copyright notice,
11+
* this list of conditions and the following disclaimer.
12+
* 2. Redistributions in binary form must reproduce the above copyright notice,
13+
* this list of conditions and the following disclaimer in the documentation
14+
* and/or other materials provided with the distribution.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
20+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
* POSSIBILITY OF SUCH DAMAGE.
27+
* #L%
28+
*/
29+
30+
open module org.scijava.execute {
31+
32+
exports org.scijava.execute;
33+
34+
requires org.scijava.common3;
35+
requires transitive org.scijava.struct;
36+
37+
}

0 commit comments

Comments
 (0)