Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create mutation APIs #230

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Create mutation APIs #230

wants to merge 10 commits into from

Conversation

axmmisaka
Copy link
Collaborator

@axmmisaka axmmisaka commented Sep 6, 2023

Successor of #193 as it was too messy.

This PR:

  1. Added necessary capabilities for reactors to create other reactors, resolve ownership issues, and make connections
  2. Added mutation sandbox API that could access these capabilities.

TODO:

  • Add more checks

@axmmisaka axmmisaka changed the base branch from master to mutation/full September 7, 2023 04:16
@axmmisaka axmmisaka mentioned this pull request Sep 7, 2023
9 tasks
axmmisaka and others added 9 commits October 17, 2023 17:40
0. `canConnect` doesn't experience situations where throwing Error is required.
1. `canConnect` is solely for testing and should not throw.
2. `connect` and `connectMulti` should throw. Simply return result from `canConnect` and throw in functions that calls them.
Most of them were achieved by a dirty hack: by changing `toBe(true)` to be `toBeFalsy()` and vice versa.
The negation of truthiness is because if connection can be established, we return 0, which is falsy.
Otherwise we return an error enum which is truthy. This is a bit C-esque and not JS-y, but let's keep it this way as of now.
Throw-catch would technically work, but it's not technically an error because we are **testing** if a connection can be established. Returning an error would also technically work, and we can add some type matching to make it work more smoothly, but as of now I intend to keep it this way.

One WIP would be to change `toBeTruthy` to the actual error code, but then some tests might break. We will need to investigate instead of coding tests based on the results.
1. Implemented ConnectablePort that can be used as `Variable`
2. Refactored ConnectablePort with function overloading at the same time to facilitate better type check (but due to TS limitation there's no type narrowing, see microsoft/TypeScript#22609)
3. Made tests conform to the new connection API
1. Adapt Sieve by simply using ConnectablePort
2. Adapt Online Facility Location by using ConnectablePort *and* making necessary changes to reflect the actual logic, as discussed with @lhstrh. In this case, two sources: an OutPort (port A), and a mutation, wants to write to an OutPort (port B), but at different times. The correct thing to do, then, will be to make the mutation have its own OutPort (port C) to write to, and when it wants to write to port B, it disconnects A->B, makes connection C->B, and write to C.
Specifically ones that are related to causality graph and `ConnectablePort` - that is, declaring `ConnectablePort` in a mutation should not create dependency between them, but connection between ports should.
…lways check against the global precedence graph.
…make connections

0. Added _addChild and _addSibling necessary for mutation APIs
1. Solved issues related to hierarchy and ownership.
@axmmisaka axmmisaka force-pushed the mutation/create-reactor-api branch from 5b53bf7 to bd2290b Compare October 18, 2023 00:41
@axmmisaka axmmisaka changed the base branch from mutation/full to master October 25, 2023 20:23
@axmmisaka axmmisaka changed the base branch from master to mutation/sidetask/refactor-canconnect October 25, 2023 20:23
@axmmisaka axmmisaka force-pushed the mutation/sidetask/refactor-canconnect branch 2 times, most recently from 286bc49 to 0e1f736 Compare December 13, 2023 01:04
@lhstrh lhstrh force-pushed the mutation/sidetask/refactor-canconnect branch from 0e1f736 to d140fdc Compare October 12, 2024 22:05
Base automatically changed from mutation/sidetask/refactor-canconnect to master October 12, 2024 22:35
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