mirror of
https://github.com/Start9Labs/patch-db.git
synced 2026-03-26 18:31:53 +00:00
Soundness and performance audit (17 fixes): - See AUDIT.md for full details and @claude comments in code Repo restructure: - Inline json-ptr and json-patch submodules as regular directories - Remove cbor submodule, replace serde_cbor with ciborium - Rename patch-db/ -> core/, patch-db-macro/ -> macro/, patch-db-macro-internals/ -> macro-internals/, patch-db-util/ -> util/ - Purge upstream CI/CD, bench, and release cruft from json-patch - Remove .gitmodules Test fixes: - Fix proptest doesnt_crash (unique file paths, proper close/cleanup) - Add PatchDb::close() for clean teardown Documentation: - Add README.md, ARCHITECTURE.md, CONTRIBUTING.md, CLAUDE.md, AUDIT.md - Add TSDocs to TypeScript client exports Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2.2 KiB
2.2 KiB
CLAUDE.md
patch-db is a JSON Patch–based database with a Rust backend and TypeScript client.
Where to look
| Need | File |
|---|---|
| What this project is, quick start examples | README.md |
| Project structure, crate details, data flow, storage format, concurrency | ARCHITECTURE.md |
| Build commands, testing, code style, making changes | CONTRIBUTING.md |
Key files
| Area | Path |
|---|---|
| Core API | core/src/store.rs — PatchDb, TypedPatchDb, Store, MutateResult |
| Types | core/src/patch.rs — Revision, Dump, DiffPatch, diff() |
| Subscriptions | core/src/subscriber.rs — DbWatch, TypedDbWatch, Subscriber, Broadcast |
| Model system | core/src/model.rs — HasModel, Model, ModelExt, Pointer |
| Derive macro | macro-internals/src/lib.rs — HasModel derive implementation |
| Error types | core/src/lib.rs — Error enum, re-exports |
| JSON Pointer | json-ptr/src/lib.rs — JsonPointer, ROOT, path navigation |
| JSON Patch | json-patch/src/lib.rs — Patch, PatchOperation, diff(), patch() |
| TS client | client/lib/patch-db.ts — PatchDB<T> class |
| TS patch lib | client/lib/json-patch-lib.ts — client-side patch application |
| TS types | client/lib/types.ts — Revision, Dump, Update, PatchOp |
Operating rules
- Wire format — Rust and TS define
Revision,Dump, and patch operations independently. Changes to one side must be mirrored in the other. See the cross-layer section in CONTRIBUTING.md. - Patch operations — Only
add,remove, andreplaceare used. The TS client does not implementtest,move, orcopy. - Immutable patch application — The TS client applies patches by shallow-copying objects/arrays, not mutating in place. This is intentional for UI framework change detection.
HasModelderive — Respects serde attributes (rename_all,rename,flatten,tag,content). Generated accessors follow the patternas_<field>(),as_<field>_mut(),into_<field>().- Error handling — Rust uses
thiserrorwith theErrorenum incore/src/lib.rs. TS does not have formal error types.