Jaseci-Labs / jaseci

The Official Jaseci Code Repository
https://jaseci.org
155 stars 208 forks source link

[Bug] [Jac Cloud] With Entry / Exit Ability does not follow Jaclang #1346

Closed ChrisIsKing closed 1 week ago

ChrisIsKing commented 1 week ago

Describe the bug

The behavior of the with entry and with exitabilities in walkers is inconsistent between jac-cloud when running with jac serve and core JacLang using jac run. Specifically, in core JacLang, the with exit ability is executed only once at the end of the walker's walk, while in jac-cloud (when using jac serve), the with exit abilitytriggers on every node exit.

To Reproduce

  1. Install jac-cloud
  2. Run the following example in both JacLang (jac run) and jac-cloud (jac serve):
node test_node {
    has value: int = 0;
}

walker create_node {
    has value: int;

    obj __specs__ {
        static has auth: bool = False;
    }

    can create_node with `root entry {
        root ++> (node_obj:=test_node(value=self.value));
        print(jid(node_obj));
        report node_obj;
    }
}

walker fetch_node {
    has node_id: str;

    obj __specs__ {
        static has auth: bool = False;
    }

    can fetch_node with `root entry {
        # grab the node with the given id
        node_obj = &self.node_id;
        report node_obj;
    }
}

walker test_walker {
    has visited_nodes: list = [];

    obj __specs__ {
        static has auth: bool = False;
    }

    can traverse with `root entry {
        visit [-->];
    }

    can log_visit with object exit {
        self.visited_nodes.append(here);
    }

    can print_visited_nodes with exit {
        print(self.visited_nodes);
    }
}

In both JacLang and Jac Cloud, the with exit ability should execute only once, at the end of the entire walker execution, not after each node exit. This ensures consistent behavior, where the final state of the walker (e.g., visited_nodes) is processed and output at the end of the walker's walk.

amadolid commented 1 week ago

Hello @ypkang , @ChrisIsKing ,

Please let me know your thoughts about this PR https://github.com/Jaseci-Labs/jaseci/pull/1354

ChrisIsKing commented 1 week ago

Closing issue. Fixed in PR #1353.