jac-sv-persistence

Model and query graph-persisted data in Jac server endpoints with schema migration support.

Updated Jul 26, 2026
One-click install
npx skills add https://github.com/PMN123/trapdoor --skill jac-sv-persistence-pmn123
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: jac-sv-persistence
Source: https://github.com/PMN123/trapdoor/tree/main/.agents/skills/jac-sv-persistence
Command: npx skills add https://github.com/PMN123/trapdoor --skill jac-sv-persistence-pmn123

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Server-side Jac code needs a reliable way to store, query, and evolve relational data without a separate ORM or database layer, and schema edits must not silently destroy persisted rows. ## Core Features & Use Cases - Graph-as-database modeling: Create entities by attaching nodes to root with typed edges, then query them with list-comprehension traversals, bracket predicates, and len() aggregation. - Find-by-id and view models: Resolve nodes with jid() loops or O(1) jobj() lookups, and project viewer-relative to_view() view models for endpoint responses. - Schema evolution without data loss: Handle field renames, class renames, and type changes via schema_alias, schema_drop, and schema_upgrade, with attic preservation and quarantine recovery through jac db commands. - Use Case: When a renamed field causes users to apparently lose data, declare a schema_alias so old values flow into the new field instead of the attic. ## Quick Start Ask the AI 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 persisted nodes in a Jac server endpoint?

Query persisted nodes with list-comprehension traversals like [root -->][?:Post], adding bracket predicates such as [?published] to filter. Aggregate with len() since there is no count() form, and writes persist automatically once a node is reachable from root.

How do I find a Jac node by id in server code?

Find a node by id using either a loop over [root -->] comparing jid(n) to the target id, or jobj(id) with an isinstance check for O(1) lookup. Never use Python id(), which changes every restart and silently returns empty results.

Does Jac persistence support MongoDB instead of SQLite?

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

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

A renamed field without a declared alias looks like a remove-plus-add: old values move to the recoverable attic and the new field reads its default. Declare schema_alias("new", stored="old") inside __jac_schema__ so values flow into the renamed field.

Why do Jac endpoints return Invalid anchor id errors?

Invalid anchor id 500 errors come from stale anchors persisted by a previous run under a different schema. In development, stop the server, delete .jac/data/, and restart; in production, use the alias and quarantine machinery via jac db commands instead.