mirror of
https://github.com/penpot/penpot.git
synced 2026-11-26 21:00:32 +00:00
📚 Consolidate file change pipeline guidance
Keep construction, application, compaction, and schema validation in one memory and update frontend and backend references. AI-assisted-by: gpt-6.1-terra
This commit is contained in:
parent
32fb7267cc
commit
8a907c49a8
@ -1,7 +1,7 @@
|
||||
# Backend graph experiment
|
||||
|
||||
- Start at `app.graph.ingest` for cold projection, `app.graph.sync` for change application, `app.graph.schema.contract` for what gets projected, and `app.graph.debug` for session ownership and export. `app.http.debug` registers the routes; `backend/resources/app/templates/graph-console.tmpl` is the browser client.
|
||||
- PostgreSQL file data remains authoritative. Cold projection and incremental sync must produce the same graph for the same file state; a Penpot shape-tree change can require updates to parent/frame columns, edges and ordered child lists together. Use `mem:common/changes-architecture` for change semantics. A new file attribute does not belong in the graph by default: decide it in the projection contract.
|
||||
- PostgreSQL file data remains authoritative. Cold projection and incremental sync must produce the same graph for the same file state; a Penpot shape-tree change can require updates to parent/frame columns, edges and ordered child lists together. Use `mem:common/changes` for change semantics. A new file attribute does not belong in the graph by default: decide it in the projection contract.
|
||||
- Cold ingest writes graph provenance only after the base projection and derived transforms finish. Incremental sync consumes persisted file changes from file-topic Pub/Sub, not the console WebSocket. A browser reconnect refreshes the view but does not recover lost graph changes. The dropping buffer and revision gaps do not trigger replay; surface drift and reload from PostgreSQL. A failed batch can leave partial graph state; don't treat it as an atomic PostgreSQL transaction. Keep skipped changes and incomplete revisions visible.
|
||||
- A session belongs to a profile, not a tab. Reload/replacement and unload own cleanup; do not assume TTL eviction. Sync, query and export use the same session lock: a long query blocks sync. Teardown closes the channel and resources, but does not take that lock; account for in-flight operations when changing the lifecycle. The Arrow allocator must outlive the Ladybug connection and database because Ladybug can retain staged Arrow buffers. Close the allocator last, including on failure.
|
||||
- The console can read whole projected files and export their data. Keep routes behind both `:graph` and `/dbg` authorization, and preserve the engine's prepare/bind and read-only gate; text matching is not a substitute. Keep graph loading off the flag-disabled boot path. On a Ladybug or JVM upgrade, check graph-enabled startup, Arrow ingest, binder behavior and sync parity. Versions and JVM flags live in `backend/deps.edn` and the launch scripts.
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
# Common change application
|
||||
|
||||
- Start at `app.common.files.changes` and the shape-tree helpers. `process-changes` validates the change vector once by default, reduces it and then processes collected touched changes; `verify? false` is for callers that already validated. Component-specific touched and copy rules are in `mem:common/components`.
|
||||
- `:set` delegates to `ctn/set-shape-attr`; `:assign` decodes attrs before applying per-attr sets.
|
||||
- `shape-tree/add-shape` falls back invalid parents or frames to root and keeps parent `:shapes` a vector without duplicate IDs. `delete-shape` removes descendants from the objects map as well as unlinking the parent; render-wasm deletion has different undo internals.
|
||||
- Page-object maps can carry metadata indexes. Rebuild them with `start-page-index` / `update-page-index` as appropriate; frontend commit application calls `ctst/update-object-indices` after page changes. For change construction and undo see `mem:common/changes-architecture`.
|
||||
- `update-file` also uses change-scoped schema validation: `touched-page-ids` selects pages while non-page data is checked whole. Register new change types as page-writing or file-level; unknown types fall back to the full schema check, which loads every page.
|
||||
@ -1,7 +0,0 @@
|
||||
# File changes and undo
|
||||
|
||||
- File changes are both the persistence payload and the basis for undo. Use the production change pipeline rather than editing object maps directly. Start in `app.common.files.changes` for schemas and application, `app.common.files.changes-builder` for redo/undo construction, and `app.common.files.changes-merge` for compaction.
|
||||
- Compaction must preserve redo and undo order: merge `:reg-objects` per container and put the registrations after the changes that resize the children. Never compact across commit boundaries; the backend can reject individual commits by `commit-id`. See `mem:frontend/workspace-state-persistence-subtleties` for the save order.
|
||||
- Don't send a deleted component's entire object map with a metadata-only edit. Scope shape edits to `:component-id` using the builder's container context. In component metadata, omitted `:objects` preserves stored shapes; explicit nil clears them. Reserve `:objects? true` for repairs that intentionally move or clear the whole map.
|
||||
- Apply fixture edits through `app.common.test-helpers.files/apply-changes` so tests exercise the production applier. Disable fixture validation only for intentionally invalid intermediate states. See `mem:common/testing`.
|
||||
- For components, touched groups, referential integrity and live diagnosis see `mem:common/components`; for change application and schema validation see `mem:common/change-application`.
|
||||
16
.serena/memories/common/changes.md
Normal file
16
.serena/memories/common/changes.md
Normal file
@ -0,0 +1,16 @@
|
||||
# File changes
|
||||
|
||||
- File changes are both persistence payloads and the basis for undo. Start at `app.common.files.changes` for schemas and application, `app.common.files.changes-builder` for redo/undo construction and `app.common.files.changes-merge` for compaction. Use the production pipeline rather than editing object maps directly.
|
||||
|
||||
## Construction and compaction
|
||||
|
||||
- Preserve redo and undo order when compacting: merge `:reg-objects` per container and place registrations after changes that resize children. Never compact across commit boundaries; the backend can reject individual commits by `commit-id`. Client save ordering is in `mem:frontend/workspace-state-persistence-subtleties`.
|
||||
- Do not send a deleted component's entire object map for a metadata-only edit. Scope shape edits to `:component-id` using the builder's container context. Omitted `:objects` preserves stored shapes; explicit nil clears them. Reserve `:objects? true` for repairs that intentionally move or clear the whole map.
|
||||
- Apply fixture edits through `app.common.test-helpers.files/apply-changes`; disable its validation only for intentionally invalid intermediate states. See `mem:common/testing`.
|
||||
|
||||
## Application and schema validation
|
||||
|
||||
- `process-changes` validates the change vector once by default, reduces it and then processes collected touched changes; `verify? false` is for callers that already validated. `:set` delegates to `ctn/set-shape-attr`, while `:assign` decodes attrs before per-attr sets. Component touched and copy rules are in `mem:common/components`.
|
||||
- `shape-tree/add-shape` falls back invalid parents or frames to root and keeps parent `:shapes` a vector without duplicate IDs. `delete-shape` removes descendants from the objects map as well as unlinking the parent; render-wasm deletion has different undo internals.
|
||||
- Page-object maps can carry metadata indexes. Rebuild them with `start-page-index` / `update-page-index` as appropriate; frontend commit application calls `ctst/update-object-indices` after page changes.
|
||||
- `update-file` uses change-scoped schema validation: `touched-page-ids` selects pages while non-page data is checked whole. Register new change types as page-writing or file-level; unknown types fall back to the full schema check, which loads every page. Referential integrity and repair are in `mem:common/components`.
|
||||
@ -20,7 +20,7 @@ Start at `app.common.types.component`, `app.common.types.container`, `app.common
|
||||
|
||||
## Referential integrity and repair
|
||||
|
||||
- Referential and semantic validation in `app.common.files.validate` runs for files with `"components/v2"`; it visits the root, orphan shapes and component records. `validate-file!` raises `:validation` / `:referential-integrity` with details. `update-file` uses change-scoped validation of affected pages and components; schema validation is separate in `mem:common/change-application`.
|
||||
- Referential and semantic validation in `app.common.files.validate` runs for files with `"components/v2"`; it visits the root, orphan shapes and component records. `validate-file!` raises `:validation` / `:referential-integrity` with details. `update-file` uses change-scoped validation of affected pages and components; schema validation is separate in `mem:common/changes`.
|
||||
- `repair-file` produces redo changes that callers must apply or persist. `repair-file-until-valid` stops on no errors, unchanged data, a stable error fingerprint without `:shape`, or its iteration limit. Check the fingerprint before another pass; backend `PointerMap` equality is pointer identity. Multiple `:set` repairs on one shape can need multiple passes because each repair starts from the original file data.
|
||||
- For `:ref-shape-not-found`, repair can restore a local component's `:main-instance-id` when the recorded main is missing but its matching main exists on the recorded page. Otherwise it tries a near-main reassignment or detaches the copy subtree.
|
||||
- `:missing-slot` is a real swap only when the copy sub-head's `:shape-ref` is no longer a child of the near main parent. A sibling at a different position is a reorder, not a swap; assigning a slot blocks normal sync. `find-near-match` is a repair heuristic, not a positional validity rule. Migration 0019 uses the same membership rule; see `mem:common/file-migrations`.
|
||||
|
||||
@ -33,8 +33,7 @@ Geometry and layout:
|
||||
- Layout/grid assignment, deassignment, metadata cleanup, and auto-positioning: `mem:common/layout-grid-subtleties`.
|
||||
|
||||
Change pipeline, validation, and migrations:
|
||||
- Change records, undo/redo architecture, changes-builder API, and production-path mutation guidance: `mem:common/changes-architecture`.
|
||||
- Change application, shape-tree edits and change-scoped schema validation: `mem:common/change-application`.
|
||||
- Change construction, undo/redo, application, compaction and schema validation: `mem:common/changes`.
|
||||
- Adding, renumbering or replacing a file migration: `mem:common/file-migrations`.
|
||||
|
||||
Components, variants, and debugging:
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# Workspace commits, rebase and undo
|
||||
|
||||
- Start at `app.main.data.changes`, `app.main.data.persistence.commits` and `app.main.data.workspace.undo`. For the shared change vocabulary see `mem:common/changes-architecture`; for save ordering see `mem:frontend/workspace-state-persistence-subtleties`.
|
||||
- Start at `app.main.data.changes`, `app.main.data.persistence.commits` and `app.main.data.workspace.undo`. For the shared change vocabulary see `mem:common/changes`; for save ordering see `mem:frontend/workspace-state-persistence-subtleties`.
|
||||
- `commit-changes` requires edit permission, no historical preview and no save-failure lock. Its refusal completes an empty stream, not nil. `:ignore-save-lock` is for rollback compensation and information derived from existing commits (position data, component touch), not user edits or an origin allowlist. Remote changes apply through `commit`, outside this local gate.
|
||||
- When a peer commit arrives, undo pending edits for that file, apply the remote change and replay local redo. Read pending edits from both the save queue **and** the unflushed buffer; otherwise the local and server order can disagree. Isolate files and versions, and keep index updates for all replay legs.
|
||||
- An undo group is one user action even if it spans several files; dependent commits such as component sync must inherit it. Persistence uses this same group for rollback. A stacked commit that records undo may inherit the current history entry's group; a repair that records no undo must not inherit it or failure could roll back the previous user action. Let an open nonempty transaction keep its grouping.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user