Files
patch-db/CLAUDE.md
Matt Hill 86b0768bbb audit fixes, repo restructure, and documentation
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>
2026-02-23 19:06:42 -07:00

2.2 KiB
Raw Blame History

CLAUDE.md

patch-db is a JSON Patchbased 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.rsPatchDb, TypedPatchDb, Store, MutateResult
Types core/src/patch.rsRevision, Dump, DiffPatch, diff()
Subscriptions core/src/subscriber.rsDbWatch, TypedDbWatch, Subscriber, Broadcast
Model system core/src/model.rsHasModel, Model, ModelExt, Pointer
Derive macro macro-internals/src/lib.rsHasModel derive implementation
Error types core/src/lib.rsError enum, re-exports
JSON Pointer json-ptr/src/lib.rsJsonPointer, ROOT, path navigation
JSON Patch json-patch/src/lib.rsPatch, PatchOperation, diff(), patch()
TS client client/lib/patch-db.tsPatchDB<T> class
TS patch lib client/lib/json-patch-lib.ts — client-side patch application
TS types client/lib/types.tsRevision, 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, and replace are used. The TS client does not implement test, move, or copy.
  • 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.
  • HasModel derive — Respects serde attributes (rename_all, rename, flatten, tag, content). Generated accessors follow the pattern as_<field>(), as_<field>_mut(), into_<field>().
  • Error handling — Rust uses thiserror with the Error enum in core/src/lib.rs. TS does not have formal error types.