Skip to content

Commit

Permalink
[BUGFIX]: Missing connected==True on retrieval; Access validation on …
Browse files Browse the repository at this point in the history
…entry
  • Loading branch information
amadolid committed Jul 12, 2024
1 parent 30232ce commit cf3d2d7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion jaclang/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ def run(
# TODO: handle no override name
if walker:
walker_module = dict(inspect.getmembers(loaded_mod)).get(walker)
if walker_module and (architype := jctx.entry.architype):
if (
walker_module
and jctx.validate_access()
and (architype := jctx.entry.architype)
):
Jac.spawn_call(architype, walker_module())
else:
print(f"Walker {walker} not found.")
Expand Down
4 changes: 4 additions & 0 deletions jaclang/core/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ def close(self) -> None:
"""Clean up context."""
self.datasource.close()

def validate_access(self) -> bool:
"""Validate access."""
return self.root.has_read_access(self.entry)

@staticmethod
def get(options: Optional[dict[str, Any]] = None) -> ExecutionContext:
"""Get or create execution context."""
Expand Down
6 changes: 4 additions & 2 deletions jaclang/core/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def get(self, anchor: dict[str, Any]) -> Anchor:
e for edge in anchor.pop("edges") if (e := EdgeAnchor.ref(edge))
],
access=access,
connected=True,
**anchor,
)
nanch.architype = NodeArchitype.get(name or "Root")(
Expand All @@ -178,17 +179,18 @@ def get(self, anchor: dict[str, Any]) -> Anchor:
source=NodeAnchor.ref(anchor.pop("source")),
target=NodeAnchor.ref(anchor.pop("target")),
access=access,
connected=True,
**anchor,
)
eanch.architype = EdgeArchitype.get(name or "GenericEdge")(
__jac__=eanch, **architype
)
return eanch
case ObjectType.walker:
wanch = WalkerAnchor(access=access, **anchor)
wanch = WalkerAnchor(access=access, connected=True, **anchor)
wanch.architype = WalkerArchitype.get(name)(__jac__=wanch, **architype)
return wanch
case _:
oanch = Anchor(access=access, **anchor)
oanch = Anchor(access=access, connected=True, **anchor)
oanch.architype = Architype(__jac__=oanch)
return oanch

0 comments on commit cf3d2d7

Please sign in to comment.