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/PMN123/trapdoor --skill jac-walker-patterns-pmn123
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: jac-walker-patterns
Source: https://github.com/PMN123/trapdoor/tree/main/.agents/skills/jac-walker-patterns
Command: npx skills add https://github.com/PMN123/trapdoor --skill jac-walker-patterns-pmn123

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing walkers in Jac's Object-Spatial Programming model involves subtle semantics around traversal, reporting, and entry-point dispatch that cause frequent bugs like empty report lists, off-by-one counting, and misused self/here keywords. This Skill encodes verified patterns and pitfalls so walker code works correctly the first time. ## Core Features & Use Cases - Traversal Patterns: Covers visit/report mechanics, spawn results, disengage vs skip, exit abilities, breadth-first vs depth-first queueing, and the get-or-create visit ... else idiom. - Report Channel Guidance: Explains typed has reports: list[T] = [] channels, accumulate-then-report-once style, nested spawn behavior, and safe access to empty reports. - Pitfall Reference: Documents verified failure modes such as the removed root() call form, visit snapshot semantics, generic with entry not being a catch-all, and walker-side vs node-side keyword pairs. - Use Case: When building a Jac API endpoint that must find a node by jid and mutate it, apply the lookup-base walker inheritance pattern so one base walker resolves the target and each action walker subclasses it with a single entry ability. ## Quick Start Load this Skill whenever creating, editing, or debugging Jac walker traversal or OSP code, and pair it with jac-node-edge-patterns for the graph shape the walker moves through.

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 a with NodeType entry clause, and drive movement with visit [-->]. Spawn it with root spawn WalkerName() and read results from result.reports.

Why is my Jac walker report list empty or failing with E1050?

E1050 occurs when has reports: list[T] lacks the = [] default, making reports a required spawn parameter. Always declare has reports: list[T] = []; and accumulate values, then report once from an exit ability.

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

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

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

Use def:pub when the walker never visits anything and is just one can run with Root entry that reports a value. Parameters replace has fields and a typed return replaces report, while root binds the same in both shapes.

Why does my walker entry fire on the spawn node and cause off-by-one counts?

The node you spawn on runs its matching entry before any visit, including the origin node. Fix it by spawning on root and visiting [-->] to reach the intended children, or guard the origin inside the entry.

How do I implement get-or-create node lookup in Jac?

Use visit [here-->[?:Type, field == value]] else { fresh = here ++> Type(...); visit fresh; }. The else body runs only when the visit enqueued nothing, so found and created nodes share the same downstream ability.