sqlstruct 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,69 @@
1
+ ---
2
+ name: jujutsu
3
+ description: Use when working in a Jujutsu (jj) repository, when the user requests jj version control, or when translating Git tasks into Jujutsu workflows.
4
+ ---
5
+
6
+ # Jujutsu operations
7
+
8
+ Prefer the Squash Workflow. Use `jj` for repository mutations in jj repositories, including colocated Git repositories. Respect an explicitly requested workflow and project conventions.
9
+
10
+ ## Orient before changing history
11
+
12
+ - Run `jj --version`, `jj status`, `jj log --limit 12`, and `jj bookmark list`. Use installed `jj <command> --help` for version-sensitive flags. If jj is unavailable, report that; do not silently substitute Git.
13
+ - `@` is a commit containing the working copy; commands normally snapshot edits automatically. There is no Git index or separate staging step. Ignored files are not automatically included.
14
+ - Prefer change IDs for targets that will be rewritten; commit hashes change on rewrite. Quote compound revsets. `@-` means parent(s), so use an explicit target when `@` has multiple parents.
15
+ - Identify the task base and any existing work before starting. `jj new BASE` preserves the previous change and switches to a new child of BASE. Never fold unrelated work into the task or abandon it to obtain a clean workspace.
16
+ - Bookmarks name commits; creating a child does not advance a bookmark. Rewriting its commit normally moves the bookmark with it. Remote bookmarks use `NAME@REMOTE`; inspect rather than assuming `main` or `origin`.
17
+
18
+ ## Default: Squash Workflow
19
+
20
+ Keep a described task commit beneath an undescribed working child. From a verified BASE:
21
+
22
+ ```sh
23
+ jj new BASE -m "Implement task" # task commit; record its change ID as TASK
24
+ jj new # scratch working child
25
+ # Edit and run relevant checks.
26
+ jj diff
27
+ jj squash --into TASK --use-destination-message path/to/file
28
+ # Repeat as work becomes ready; squash all only when every remaining edit belongs.
29
+ jj squash --into TASK --use-destination-message
30
+ jj diff -r TASK
31
+ jj status
32
+ ```
33
+
34
+ TASK and BASE are placeholders to replace with verified revisions. A full squash abandons the emptied source and creates a fresh empty working child; do not add `jj new` after every squash. Partial squashes leave unaccepted edits in `@`. If unrelated leftovers remain, preserve them and use `jj new TASK` to finish with an empty child; report the saved change ID.
35
+
36
+ For the next logical commit, create a described child of TASK, then its scratch child. For review fixes, use `jj new TASK` and squash back into TASK. If published history must stay unchanged, create a new described fix commit and move the PR bookmark forward instead.
37
+
38
+ ## Common tasks: Git intent → idiomatic jj
39
+
40
+ Replace uppercase placeholders. Interactive commands require an available terminal/UI; prefer path selection for unattended operation.
41
+
42
+ | Git task | jj operation |
43
+ |---|---|
44
+ | Clone / initialize | `jj git clone URL DIR` / `jj git init DIR`; adopt an existing Git checkout with `jj git init --colocate` inside it. |
45
+ | Status / diff / show / log | `jj status`; `jj diff`; `jj show REV`; `jj log`. `jj diff -r TASK` reviews the task commit rather than scratch edits. |
46
+ | Add files and amend | `jj squash --into TASK --use-destination-message PATH...`. For hunks: `jj squash -i --into TASK --use-destination-message`. |
47
+ | Commit message / amend message | `jj describe -r TASK -m "Message"`; content already lives in commits. |
48
+ | Branch / switch / stash | `jj new BASE` creates an anonymous branch; `jj new SAVED` resumes work above a saved change. No stash needed. `jj edit REV` edits that existing commit directly; use deliberately. |
49
+ | Named branch / tracking | `jj bookmark set NAME -r TASK`; `jj bookmark track NAME@REMOTE`. |
50
+ | Fetch / pull --rebase | `jj git fetch --remote REMOTE`, inspect, then `jj rebase -s STACK_ROOT -o BASE`. `-s` moves the root and descendants; `-r REV` moves only selected revisions. `-b TIP` selects a branch relative to the destination. |
51
+ | Merge | `jj new LEFT RIGHT -m "Merge ..."`; resolve conflicts in the merge commit. |
52
+ | Cherry-pick | `jj duplicate REV -o DEST`; inspect the returned new change ID. This copies the diff without moving the original. |
53
+ | Interactive rebase: fixup / split / reorder | `jj squash --from FIXUP --into TASK --use-destination-message`; `jj split -r REV -m "Selected part" PATH...` (or `-i`); `jj rebase -r REV -A AFTER`. Inspect descendants afterward. |
54
+ | Restore file / discard scratch edit | `jj restore --from @- PATH` for a single-parent scratch change. This discards that path's scratch edits; scope it carefully. |
55
+ | Drop a commit | `jj abandon REV`; descendants are rebased. Review the selected commit first. |
56
+ | Revert published commit | `jj revert -r BAD -o TIP` creates a new inverse change; inspect its ID and use `jj new REVERT_ID` to continue above it. |
57
+ | Reflog / recovery | `jj op log`; `jj op show OP`; `jj undo` for the latest operation. For an earlier mistake with later work, `jj op revert OP --what repo` applies its inverse; inspect resulting conflicts. Older releases may expose this as `jj undo OP`; check help. `jj op restore OP` rolls back the entire local state. |
58
+ | Git worktree | `jj workspace add -r BASE DIR`; the new workspace has its own working child. Use separate workspaces for concurrent agents. |
59
+
60
+ ## Conflicts, publishing, and recovery
61
+
62
+ - Rewrites automatically rebase descendants and can record conflicts without stopping. Inspect `jj log -r 'conflicts()'` and `jj resolve --list -r REV`. Resolve in the conflicted revision with `jj resolve -r REV`, or `jj edit REV`, edit markers, and snapshot with `jj status`; return to the scratch child afterward. There is no `rebase --continue` or `git add` resolution step. Verify affected descendants and tests.
63
+ - When publishing is authorized, point the PR bookmark at the task tip, not its empty scratch child: `jj bookmark set NAME -r TASK`, then `jj git push --remote REMOTE --bookmark NAME --dry-run`, then the same push without `--dry-run`. Use explicit bookmark scope. New bookmarks are tracked by current jj; consult help if an older release requires `--allow-new`.
64
+ - Push uses remote-state checks comparable to force-with-lease. On rejection, fetch and inspect remote changes or bookmark conflicts before retrying. Do not bypass immutability or overwrite collaborators' work to make a push succeed. A jj push updates Git refs; create PRs through the hosting service's tools.
65
+ - Local operation recovery does not undo remote pushes. Inspect the operation before recovery; prefer a targeted inverse when later work must survive. Recovery can create divergent versions of a change: inspect `jj log -r 'change_id(ID)'`, select versions by commit hash, and reconcile their contents before abandoning obsolete versions. Check status, graph, bookmarks, and affected diffs after history changes.
66
+
67
+ ## Sources
68
+
69
+ Workflow adapted from [Steve Klabnik's Jujutsu tutorial](https://steveklabnik.github.io/jujutsu-tutorial/introduction/introduction.html), especially [The Squash Workflow](https://steveklabnik.github.io/jujutsu-tutorial/real-world-workflows/the-squash-workflow.html). Command spellings checked against jj 0.39.0; installed CLI help takes precedence over older tutorial examples. Consult [official documentation](https://docs.jj-vcs.dev/latest/) for additional details.
@@ -0,0 +1,3 @@
1
+ interface:
2
+ display_name: "Jujutsu"
3
+ short_description: "Operate jj repositories using the Squash Workflow"
@@ -0,0 +1,210 @@
1
+ ---
2
+ name: lat-md
3
+ description: >-
4
+ Writing and maintaining lat.md documentation files — structured markdown that
5
+ describes a project's architecture, design decisions, and test specs. Use when
6
+ creating, editing, or reviewing files in the lat.md/ directory.
7
+ ---
8
+
9
+ # lat.md Authoring Guide
10
+
11
+ This skill covers the syntax, structure rules, and conventions for writing `lat.md/` files. Load it whenever you need to create or edit sections in the `lat.md/` directory.
12
+
13
+ Project-specific lat documentation belongs in `lat.md/`. Do not modify this generated skill or a generated `AGENTS.md` to record project guidance: both are owned by lat tooling and may be replaced by a later `lat init`.
14
+
15
+ ## What belongs in lat.md
16
+
17
+ `lat.md/` files describe **what** the project does and **why** — domain concepts, key design decisions, business logic, and test specifications. They do NOT duplicate source code. Think of each section as an anchor that source code references back to.
18
+
19
+ Treat `lat.md/` as a focused snapshot of the current implemented state. Plans may be drafted in `lat.md/` alongside implementation, with the intent that by commit time they describe what was implemented. Otherwise, keep proposals, hypothetical designs, and future work outside `lat.md/` unless the user explicitly requests them there. A planning-only task does not require a knowledge-graph update. Do not use it as a journal or changelog, and do not grow it just to record insignificant implementation details.
20
+
21
+ Good candidates for sections:
22
+ - Architecture decisions and their rationale
23
+ - Domain concepts and business rules
24
+ - API contracts and protocols
25
+ - Test specifications (what is tested and why)
26
+ - Non-obvious constraints or invariants
27
+
28
+ Bad candidates:
29
+ - Step-by-step code walkthroughs (the code itself is the walkthrough)
30
+ - Auto-generated API docs (use tools for that)
31
+ - Journal/changelog entries for each change
32
+ - Proposals, planned features, hypothetical designs, or promises of future behavior, unless explicitly requested by the user or drafted alongside implementation to describe implemented behavior by commit time
33
+ - Temporary notes or TODOs
34
+ - Insignificant implementation details that do not change the current-state model
35
+
36
+ ## Section structure
37
+
38
+ Every section **must** have a leading paragraph — at least one sentence immediately after the heading, before any child headings or other block content.
39
+
40
+ The first paragraph must be ≤250 characters (excluding `[[wiki link]]` content). This paragraph is the section's identity — it appears in search results, command output, and RAG context.
41
+
42
+ ```markdown
43
+ # Good Section
44
+
45
+ Brief overview of what this section documents and why it matters.
46
+
47
+ More detail can go in subsequent paragraphs, code blocks, or lists.
48
+
49
+ ## Child heading
50
+
51
+ Details about this child topic.
52
+ ```
53
+
54
+ ```markdown
55
+ # Bad Section
56
+
57
+ ## Child heading
58
+
59
+ This is invalid — "Bad Section" has no leading paragraph.
60
+ ```
61
+
62
+ `lat check` enforces this rule.
63
+
64
+ ## Diagrams
65
+
66
+ Default to prose. Reserve Mermaid diagrams for concepts involving more than seven interacting subjects (such as components, states, or stages) with complex sequencing, branching, or dependencies that prose alone makes hard to follow.
67
+
68
+ The subject count alone does not justify a diagram; omit diagrams for simple sequences or relationships that a short paragraph or list explains clearly. A diagram should give users and later agents an overview of the interactions.
69
+
70
+ Keep each diagram focused on one process, use readable labels, and explain the important decisions in surrounding prose with precise source-symbol links. Prefer a small overview or several focused diagrams over one dense diagram. Use fenced `mermaid` blocks and run `lat check` to validate syntax and readability.
71
+
72
+ ## Section IDs
73
+
74
+ Sections are addressed by file path and heading chain:
75
+
76
+ - **Full form**: `lat.md/path/to/file#Heading#SubHeading`
77
+ - **Short form**: `file#Heading#SubHeading` (when the file stem is unique)
78
+
79
+ Examples: `lat.md/tests/search#RAG Replay Tests`, `cli#init`, `parser#Wiki Links`.
80
+
81
+ Configured external sources use `[[handle:path/to/file.md#Heading]]` for
82
+ Markdown headings and `[[handle:path/to/file.ts#symbol]]` for supported code
83
+ symbols. Run `lat external show <handle>` before cloning an external source;
84
+ its output includes the pinned commit and safe checkout suggestions.
85
+
86
+ ## Wiki links
87
+
88
+ Cross-reference other sections or source code with `[[target]]` or `[[target|alias]]`.
89
+
90
+ When documenting implemented behavior, prefer the narrowest relevant source-symbol link over a whole-file link. Use whole-file or directory links when discussing the module or resource as a whole, or when no supported symbol represents the target. If prose names a symbol, link that symbol directly.
91
+
92
+ ### Section links
93
+
94
+ Section links connect related concepts while keeping their stable graph identities explicit.
95
+
96
+ ```markdown
97
+ See [[cli#init]] for setup details.
98
+ The parser validates [[parser#Wiki Links|wiki link syntax]].
99
+ ```
100
+
101
+ ### Repository path links
102
+
103
+ Reference any existing file or directory beneath the project root without a fragment:
104
+
105
+ ```markdown
106
+ [[schema.sql]]
107
+ [[CHANGELOG]]
108
+ [[src/components]]
109
+ ```
110
+
111
+ Unsupported formats validate as references but cannot be opened by Lat. A `#fragment` requires a `lat.md/` section or a supported source file.
112
+
113
+ ### Source code links
114
+
115
+ Reference functions, classes, constants, and methods in source files:
116
+
117
+ ```markdown
118
+ [[src/config.ts#getConfigDir]] — function
119
+ [[src/server.ts#App#listen]] — class method
120
+ [[lib/utils.py#parse_args]] — Python function
121
+ [[src/lib.rs#Greeter#greet]] — Rust impl method
122
+ [[src/app.go#Greeter#Greet]] — Go method
123
+ [[src/app.h#Greeter]] — C struct
124
+ ```
125
+
126
+ When prose names an implementation symbol or a behavior governed by one, link the symbol instead of using a bare code span or copying its literal value. Prefer `[[src/config.ts#DEFAULT_TIMEOUT]]` (or `[[src/config.ts#DEFAULT_TIMEOUT|the default timeout]]`) over a bare identifier or copied value. Keep the behavioral explanation in prose; the link makes its implementation binding navigable and validated.
127
+
128
+ `lat check` validates that all targets exist.
129
+
130
+ ## Code refs
131
+
132
+ Tie source code back to `lat.md/` sections with `@lat:` comments:
133
+
134
+ ```typescript
135
+ // @lat: [[cli#init]]
136
+ export function init() { ... }
137
+ ```
138
+
139
+ ```python
140
+ # @lat: [[cli#init]]
141
+ def init():
142
+ ...
143
+ ```
144
+
145
+ Supported comment styles: `//` (JS/TS/Rust/Go/C/PHP) and `#` (Python/PHP).
146
+
147
+ Place one `@lat:` comment per section, at the relevant code — not at the top of the file.
148
+
149
+ ## Test specs
150
+
151
+ Describe tests as sections in `lat.md/` files. Add frontmatter to require that every leaf section has a matching `@lat:` comment in test code:
152
+
153
+ ```markdown
154
+ ---
155
+ lat:
156
+ require-code-mention: true
157
+ ---
158
+ # Tests
159
+
160
+ Authentication test specifications.
161
+
162
+ ## User login
163
+
164
+ Verify credential validation and error handling.
165
+
166
+ ### Rejects expired tokens
167
+
168
+ Tokens past their expiry timestamp are rejected with 401, even if otherwise valid.
169
+
170
+ ### Handles missing password
171
+
172
+ Login request without a password field returns 400 with a descriptive error.
173
+ ```
174
+
175
+ Each test references its spec:
176
+
177
+ ```python
178
+ # @lat: [[tests#User login#Rejects expired tokens]]
179
+ def test_rejects_expired_tokens():
180
+ ...
181
+ ```
182
+
183
+ Rules:
184
+ - Every leaf section under `require-code-mention: true` must be referenced by exactly one `@lat:` comment
185
+ - Every section MUST have a description — at least one sentence explaining what the test verifies and why
186
+ - `lat check` flags unreferenced specs and dangling code refs
187
+
188
+ ## Frontmatter
189
+
190
+ Optional YAML frontmatter at the top of `lat.md/` files:
191
+
192
+ ```yaml
193
+ ---
194
+ lat:
195
+ require-code-mention: true
196
+ ---
197
+ ```
198
+
199
+ Currently the only supported field is `require-code-mention` for test spec enforcement.
200
+
201
+ ## Validation
202
+
203
+ Always run `lat check` after editing `lat.md/` files. It validates:
204
+ - All wiki links point to existing sections, repository paths, or source code symbols
205
+ - All relative markdown links point to existing files
206
+ - Full and collapsed reference-style links have definitions
207
+ - All `@lat:` code refs point to existing sections
208
+ - Every section has a leading paragraph (≤250 chars)
209
+ - All `require-code-mention` leaf sections are referenced in code
210
+ - Every `lat.md/` directory has an accurate index
@@ -0,0 +1,47 @@
1
+ # This file is machine-generated by `gh actions-lock`.
2
+ # Do not edit by hand; run `gh actions-lock` to update.
3
+ # Docs: https://gh.io/actions-lockfile
4
+ version: 'v0.0.3'
5
+ workflows:
6
+ '.github/workflows/ci.yml':
7
+ - 'actions/checkout@v7.0.1'
8
+ - 'astral-sh/setup-uv@v10.4.0'
9
+ '.github/workflows/release.yml':
10
+ - 'actions/checkout@v7.0.1'
11
+ - 'actions/download-artifact@v8.0.2'
12
+ - 'actions/upload-artifact@v7.0.2'
13
+ - 'astral-sh/setup-uv@v10.4.0'
14
+ - 'pypa/gh-action-pypi-publish@v1.14.3'
15
+ dependencies:
16
+ 'actions/checkout@v7.0.1':
17
+ ref: 'v7.0.1'
18
+ commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1'
19
+ owner_id: 44036562
20
+ repo_id: 197814629
21
+ 'actions/download-artifact@v8.0.2':
22
+ ref: 'v8.0.2'
23
+ commit: 'sha1-9000827ccba6bdab643e8b6fd33ac0654aef8333'
24
+ owner_id: 44036562
25
+ repo_id: 192626254
26
+ 'actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405':
27
+ ref: 'v6.2.0'
28
+ commit: 'sha1-a309ff8b426b58ec0e2a45f0f869d46889d02405'
29
+ owner_id: 44036562
30
+ repo_id: 192625525
31
+ 'actions/upload-artifact@v7.0.2':
32
+ ref: 'v7.0.2'
33
+ commit: 'sha1-cf430e030ddbb5b0abf93d22962f4752f3646cd9'
34
+ owner_id: 44036562
35
+ repo_id: 192625955
36
+ 'astral-sh/setup-uv@v10.4.0':
37
+ ref: 'v10.4.0'
38
+ commit: 'sha1-1db35dd8eee11c5894872e0b383ae6c406cf738d'
39
+ owner_id: 115962839
40
+ repo_id: 846733598
41
+ 'pypa/gh-action-pypi-publish@v1.14.3':
42
+ ref: 'v1.14.3'
43
+ commit: 'sha1-7245906fb61fa33a13554f9d5fb856fe61758086'
44
+ owner_id: 647025
45
+ repo_id: 178055147
46
+ uses:
47
+ - 'actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405'
@@ -0,0 +1,60 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ branches:
9
+ - main
10
+ workflow_dispatch:
11
+
12
+ permissions: {}
13
+
14
+ jobs:
15
+ check:
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ python-version: ["3.12", "3.13", "3.14", "3.15"]
20
+ runs-on: ubuntu-latest
21
+ permissions:
22
+ contents: read
23
+ steps:
24
+ - uses: actions/checkout@v7.0.1
25
+ with:
26
+ persist-credentials: false
27
+
28
+ - uses: astral-sh/setup-uv@v10.4.0
29
+ with:
30
+ enable-cache: true
31
+ python-version: ${{ matrix.python-version }}
32
+
33
+ - name: Install dependencies
34
+ run: uv sync --locked
35
+
36
+ - name: Lint
37
+ run: uv run ruff check .
38
+
39
+ - name: Format
40
+ run: uv run ruff format --check src tests
41
+
42
+ - name: Type check
43
+ run: uv run ty check
44
+
45
+ - name: Test
46
+ run: uv run pytest
47
+
48
+ zizmor:
49
+ runs-on: ubuntu-latest
50
+ permissions:
51
+ contents: read
52
+ steps:
53
+ - uses: actions/checkout@v7.0.1
54
+ with:
55
+ persist-credentials: false
56
+
57
+ - uses: astral-sh/setup-uv@v10.4.0
58
+
59
+ - name: Audit workflows with zizmor
60
+ run: uvx zizmor .
@@ -0,0 +1,102 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ permissions: {}
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ permissions:
14
+ contents: read
15
+ steps:
16
+ - uses: actions/checkout@v7.0.1
17
+ with:
18
+ persist-credentials: false
19
+
20
+ - uses: astral-sh/setup-uv@v10.4.0
21
+ with:
22
+ enable-cache: false
23
+
24
+ - name: Verify tag matches package version
25
+ env:
26
+ TAG_NAME: ${{ github.ref_name }}
27
+ run: |
28
+ uv run python - <<'EOF'
29
+ import os, sys, tomllib
30
+ tag_version = os.environ["TAG_NAME"].removeprefix("v")
31
+ with open("pyproject.toml", "rb") as f:
32
+ pkg_version = tomllib.load(f)["project"]["version"]
33
+ if tag_version != pkg_version:
34
+ print(
35
+ f"Tag version {tag_version!r} does not match pyproject.toml version {pkg_version!r}",
36
+ file=sys.stderr,
37
+ )
38
+ sys.exit(1)
39
+ EOF
40
+
41
+ - name: Install dependencies
42
+ run: uv sync --locked
43
+
44
+ - name: Lint
45
+ run: uv run ruff check .
46
+
47
+ - name: Format
48
+ run: uv run ruff format --check src tests
49
+
50
+ - name: Type check
51
+ run: uv run ty check
52
+
53
+ - name: Test
54
+ run: uv run pytest
55
+
56
+ - name: Build package
57
+ run: uv build
58
+
59
+ - uses: actions/upload-artifact@v7.0.2
60
+ with:
61
+ name: dist
62
+ path: dist/
63
+
64
+ publish-pypi:
65
+ needs: build
66
+ runs-on: ubuntu-latest
67
+ environment:
68
+ name: pypi
69
+ url: https://pypi.org/p/sqlstruct
70
+ permissions:
71
+ id-token: write
72
+ steps:
73
+ - uses: actions/download-artifact@v8.0.2
74
+ with:
75
+ name: dist
76
+ path: dist/
77
+
78
+ - uses: pypa/gh-action-pypi-publish@v1.14.3
79
+ with:
80
+ packages-dir: dist/
81
+
82
+ create-release:
83
+ needs: publish-pypi
84
+ runs-on: ubuntu-latest
85
+ permissions:
86
+ contents: write
87
+ steps:
88
+ - uses: actions/download-artifact@v8.0.2
89
+ with:
90
+ name: dist
91
+ path: dist/
92
+
93
+ - name: Create draft GitHub Release
94
+ env:
95
+ GH_TOKEN: ${{ github.token }}
96
+ TAG_NAME: ${{ github.ref_name }}
97
+ run: |
98
+ gh release create "$TAG_NAME" dist/* \
99
+ --repo "$GITHUB_REPOSITORY" \
100
+ --draft \
101
+ --title "$TAG_NAME" \
102
+ --notes ""
@@ -0,0 +1,9 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.egg-info/
4
+ .pytest_cache/
5
+ dist/
6
+ .lat-build
7
+ .claude
8
+ .mcp.json
9
+ .codex
@@ -0,0 +1 @@
1
+ 3.15
@@ -0,0 +1,18 @@
1
+ # sqlstruct
2
+
3
+ > SQLModel for msgspec
4
+
5
+ ## Required skills
6
+
7
+ - Jujutsu for version control: ./.agents/skills/jujutsu/SKILL.md
8
+ - lat.md for project wiki: ./.agents/skills/lat-md/SKILL.md
9
+
10
+ ## Useful commands
11
+
12
+ - uv run pytest
13
+ - uv run ty check
14
+ - uv run ruff check .
15
+ - uv run ruff format --check src tests
16
+ - lat check
17
+ - gh actions-lock (updates `.github/workflows/actions.lock` after editing GitHub Actions pins)
18
+ - uvx zizmor . (audits `.github/workflows/` and the lockfile)
@@ -0,0 +1,24 @@
1
+ Metadata-Version: 2.5
2
+ Name: sqlstruct
3
+ Version: 0.1.0
4
+ Summary: SQLModel for msgspec
5
+ Requires-Python: >=3.12
6
+ Requires-Dist: msgspec>=0.22.0
7
+ Requires-Dist: sqlalchemy>=2.0
8
+ Description-Content-Type: text/markdown
9
+
10
+ # sqlstruct
11
+
12
+ SQLModel for [msgspec](https://jcristharif.com/msgspec/).
13
+
14
+ ## Development
15
+
16
+ Tooling is [uv](https://docs.astral.sh/uv/), [ruff](https://docs.astral.sh/ruff/) and [ty](https://docs.astral.sh/ty/):
17
+
18
+ ```sh
19
+ uv sync # install dependencies
20
+ uv run pytest # tests
21
+ uv run ruff format . # format
22
+ uv run ruff check . # lint
23
+ uv run ty check # type check
24
+ ```
@@ -0,0 +1,15 @@
1
+ # sqlstruct
2
+
3
+ SQLModel for [msgspec](https://jcristharif.com/msgspec/).
4
+
5
+ ## Development
6
+
7
+ Tooling is [uv](https://docs.astral.sh/uv/), [ruff](https://docs.astral.sh/ruff/) and [ty](https://docs.astral.sh/ty/):
8
+
9
+ ```sh
10
+ uv sync # install dependencies
11
+ uv run pytest # tests
12
+ uv run ruff format . # format
13
+ uv run ruff check . # lint
14
+ uv run ty check # type check
15
+ ```
@@ -0,0 +1,2 @@
1
+ config.local.yaml
2
+ .cache/
@@ -0,0 +1,6 @@
1
+ # sqlstruct Knowledge Graph
2
+
3
+ High-level architecture, domain rules, design decisions, and test specifications for sqlstruct, a SQLModel-style ORM and schema library built on `msgspec` and SQLAlchemy.
4
+
5
+ - [[overview]] — Purpose and core design decisions
6
+ - [[tests]] — Test specifications anchored to the test suite
@@ -0,0 +1,12 @@
1
+ # Overview
2
+
3
+ `sqlstruct` brings SQLModel-style ergonomics to `msgspec.Struct` models backed by SQLAlchemy.
4
+
5
+ ## Core Architecture
6
+
7
+ [[src/sqlstruct/_struct.py#SQLStruct]] subclasses `msgspec.Struct` with [[src/sqlstruct/_struct.py#SQLStructMeta]] to support both plain schema structs (`table=False`) and ORM-mapped tables (`table=True`).
8
+
9
+ - [[src/sqlstruct/_field.py#Field]] captures SQLAlchemy column options (`primary_key`, `foreign_key`, `index`, `unique`, `nullable`, `max_length`, `sa_column`) alongside `msgspec` defaults.
10
+ - [[src/sqlstruct/_types.py#get_sqlalchemy_type]] maps Python and `Optional` / `Annotated` type hints to SQLAlchemy column types.
11
+ - [[src/sqlstruct/_session.py#Session]] extends SQLAlchemy's session with `.exec()` for SQLModel-style scalar queries.
12
+ - `table=True` models sync values between SQLAlchemy's `__dict__` and `msgspec` C struct slots on instantiation, `load`, `refresh`, and attribute `set` events so `msgspec.json.encode` stays up to date.
@@ -0,0 +1,27 @@
1
+ ---
2
+ lat:
3
+ require-code-mention: true
4
+ ---
5
+ # Tests
6
+
7
+ Test specifications for sqlstruct, anchored to [[tests/test_sqlstruct.py]] and [[tests/test_e2e_sqlite.py]].
8
+
9
+ ## Package import
10
+
11
+ Verify that `sqlstruct` imports cleanly and exposes `__all__`.
12
+
13
+ ## End-to-end SQLite CRUD
14
+
15
+ Verify full insert, select, update, and delete lifecycle against a local SQLite database.
16
+
17
+ ## msgspec JSON round-trip
18
+
19
+ Verify `msgspec.json.decode`, `msgspec.convert`, and `msgspec.json.encode` interoperability with `SQLStruct` models before and after DB persistence and attribute mutation.
20
+
21
+ ## Foreign keys and joins
22
+
23
+ Verify `Field(foreign_key=...)` table relationships and multi-entity `select(Hero, Team).join(...)` queries via `Session.exec()`.
24
+
25
+ ## Column metadata and rich types
26
+
27
+ Verify index creation, unique constraint enforcement, `sa_column` overrides, `UUID`, `Enum`, and `datetime` round-tripping in SQLite.
@@ -0,0 +1,35 @@
1
+ [project]
2
+ name = "sqlstruct"
3
+ version = "0.1.0"
4
+ description = "SQLModel for msgspec"
5
+ readme = "README.md"
6
+ requires-python = ">=3.12"
7
+ dependencies = [
8
+ "msgspec>=0.22.0",
9
+ "sqlalchemy>=2.0",
10
+ ]
11
+
12
+ [dependency-groups]
13
+ dev = [
14
+ "pytest>=8",
15
+ "ruff>=0.17.5",
16
+ "ty>=0.0.104",
17
+ ]
18
+
19
+ [build-system]
20
+ requires = ["hatchling"]
21
+ build-backend = "hatchling.build"
22
+
23
+ [tool.pytest.ini_options]
24
+ testpaths = ["tests"]
25
+
26
+ [tool.ruff]
27
+ line-length = 88
28
+ target-version = "py312"
29
+
30
+ [tool.ruff.lint]
31
+ select = ["E", "F", "I", "UP", "B", "SIM"]
32
+
33
+ [tool.uv]
34
+ exclude-newer = "2 days"
35
+ cache-keys = [{ file = "pyproject.toml" }, { file = "src/**/*.py" }]
@@ -0,0 +1,14 @@
1
+ """SQLModel for msgspec."""
2
+
3
+ from sqlstruct._field import Field
4
+ from sqlstruct._session import Session, col, create_engine, select
5
+ from sqlstruct._struct import SQLStruct
6
+
7
+ __all__ = [
8
+ "Field",
9
+ "SQLStruct",
10
+ "Session",
11
+ "col",
12
+ "create_engine",
13
+ "select",
14
+ ]