Skip to content

Port dependency/precedence logic when adding a mutation #223

@axmmisaka

Description

@axmmisaka

This is a problem which troubled me for a while and I discovered it might potentially be a rather major issue.

When adding a mutation, it is necessary to declare ports. We declare a port as an argument, as things are set up currently, either as an IOPort or as a WritablePort. They are, then, handled differently in recordDeps: either as dependency or precedence to the mutation.

if (a instanceof IOPort) {
this._dependencyGraph.addEdge(
a,
reaction as unknown as Reaction<Variable[]>
);
sources.add(a);
} else if (a instanceof MultiPort) {

} else if (a instanceof WritablePort) {
this._dependencyGraph.addEdge(
reaction as unknown as Reaction<Variable[]>,
a.getPort()
);
effects.add(a.getPort());
} else if (a instanceof WritableMultiPort) {

The issue is, they are able to be converted to one another inside of the mutation (by using this.getReactor().writable(port), or (port as unknown as WritablePort<number>).getPort()), and potentially create a causality loop. Unfortunately to do connection inside of a mutation, it appears that IOPort version is required, and if we want to connect AND write to a port then conversion is necessary (either pass in an WritablePort and convert to IOPort when connecting, or pass in an IOPort and convert to WritablePort).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions