jac-sv-persistence

Model graph relationships and query persisted data from Jac server endpoints.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Server-side Jac code needs a reliable way to store entities, query them with graph traversals, and survive schema changes without losing data. This Skill teaches the graph-as-database model so endpoints create, read, update, and filter persisted nodes correctly, and so schema edits never silently destroy rows. ## Core Features & Use Cases - Graph CRUD patterns: Create nodes by attaching them to root with typed edges, read with list-comprehension traversals and bracket filters, and update via jid loops or O(1) jobj() lookups. - View model projections: Build to_view() projections with viewer-relative fields like is_mine so endpoints return sorted view objects instead of raw nodes. - Schema migration and recovery: Handle field renames with schema_alias, class renames with archetype_alias, quarantined rows with jac db commands, and backend switches between SQLite and MongoDB. - Use Case: A developer adds a published flag to a Post node, renames an old username field, and needs existing production rows to keep their values instead of landing in the attic. ## Quick Start Ask the agent to write a Jac server endpoint that creates a Post node attached to a user with a typed Wrote edge and returns all published posts as view models.

Frequently Asked Questions about jac-sv-persistence

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

FAQPage Schema
How do I query nodes by id in Jac server endpoints?▼

Use either a jid loop over [root-->][?:Type] comparing jid(node) to the target id, or jobj(id) with an isinstance check for O(1) lookup. jobj is required when the node lives under another user's root, and Python id() must never be used since it changes every restart.

How do I filter graph traversal results in Jac?▼

Append bracket predicates to the traversal, such as [root -->][?:Post][?published] for boolean fields or [?author == "alice"] for value filters. Use len() for aggregation since there is no count() form.

Does Jac persistence support MongoDB instead of SQLite?▼

Yes. Data persists to SQLite in .jac/data/ by default, and setting MONGODB_URI switches to MongoDB with a Redis L2 cache. The same node model and schema migration rules run identically on both backends.

What happens to existing data when I rename a field in Jac?▼

Without a declared schema_alias, a rename looks like remove-plus-add: old values move to the recoverable attic and the new field reads its default. Declaring schema_alias inside __jac_schema__ flows the old value into the renamed field on next load.

Why do my Jac endpoints return Invalid anchor id errors?▼

This happens when stale anchors persisted by a previous run under a different schema are loaded. In development, stop the server, delete .jac/data/, and restart; in production, use the alias and quarantine machinery with jac db commands instead.

When should I use jobj versus root traversal in Jac?▼

Use root traversal for listing and filtering nodes reachable from the current user's root. Use jobj when you have a specific id, need O(1) access, or the target node was granted from another user's root, but remember jobj never authorizes so you must enforce grants separately.