jac-walker-patterns

Guides writing and debugging graph-traversing walkers in Jac Object-Spatial Programming.

Updated Jul 26, 2026
One-click install
npx skills add https://github.com/nihalnihalani/jachacks-sf-2026 --skill jac-walker-patterns-nihalnihalani
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: jac-walker-patterns
Source: https://github.com/nihalnihalani/jachacks-sf-2026/tree/main/plugins/jac-codex/skills/jac-walker-patterns
Command: npx skills add https://github.com/nihalnihalani/jachacks-sf-2026 --skill jac-walker-patterns-nihalnihalani

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing walkers in Jac's Object-Spatial Programming model involves subtle semantics around visit, report, disengage, and entry abilities, and small mistakes cause silent traversal bugs, doubled output, or spawn failures. This Skill encodes the correct patterns and verified pitfalls so walker code works the first time. ## Core Features & Use Cases - Traversal control patterns: Covers visit/else get-or-create, breadth-first vs depth-first queueing, skip vs disengage, and eager snapshot semantics of visit references. - Reporting and spawn results: Explains typed report channels, accumulate-then-report-once from exit abilities, nested spawn behavior, and safe access to result.reports. - Walker inheritance: Documents the lookup-base pattern where a base walker resolves a target node by jid and action walkers subclass it with a single entry ability. - Use Case: When building a Jac API endpoint that must find a node by id and act on it, use this Skill to write a lookup-base walker with an isinstance guard and a disengaging action subclass instead of scattering ad-hoc traversal logic. ## Quick Start Use the jac-walker-patterns skill to write a walker that finds a node by id, updates it, and reports the result once.

Frequently Asked Questions about jac-walker-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a walker that traverses a graph in Jac?▼

Define a walker with has fields for state, add can abilities with with NodeType entry clauses that fire on arrival, and drive movement with visit [-->]. Spawn it with root spawn Walker() and read results from result.reports.

How do I return results from a Jac walker?▼

Declare a typed report channel with has reports: list[T] = [] and call report X once, typically from an exit ability after traversal completes. Omitting the = [] default makes reports a required spawn parameter and every spawn fails with E1050.

What is the difference between skip and disengage in Jac walkers?▼

skip ends only the current ability while the walker continues processing its visit queue. disengage halts the entire walker immediately and discards queued visits, making it the right choice for search-style early exits.

Why does my Jac walker report print output twice?▼

The report statement both appends to result.reports and prints each value to stdout, which causes doubled output. Accumulate matches in a has list during traversal and report once from an exit ability instead of reporting per match.

When should I use a def:pub function instead of a walker in Jac?▼

If a walker never calls visit and only runs one entry ability that reports a value, it should be a def:pub function. Parameters replace has fields, a typed return replaces report, and callers avoid the result.reports unwrap.

How do I implement get-or-create when visiting nodes in Jac?▼

Use visit [here-->[?:Type, field == value]] else { ... } where the else body runs only when the visit enqueued nothing. Inside else, connect a fresh node with ++> and visit it so the same downstream ability runs whether the node was found or created.