memstead_base/backend.rs
1//! `MemBackend` — uniform trait surface over folder, git-branch,
2//! and archive storage.
3//!
4//! Bytes-level: list / read / write / delete / move / commit /
5//! append-provenance / read-provenance. The one-engine architecture
6//! that the workspace-store rebuild produces sits above this trait;
7//! entity-mutation logic, validation, the in-memory store, and the
8//! search index live in one place regardless of which backend serves
9//! a given mount.
10//!
11//! This is the one write-side abstraction: the earlier writer
12//! trait (four write methods, its own error type) was folded into it on
13//! 2026-09-11, so a backend implements one trait and raises one error
14//! type, [`BackendError`].
15//!
16//! ## Per-backend write semantics
17//!
18//! - **Folder** — writes go to the workspace's mem subdirectory;
19//! commit is a no-op CAS-token mint (no history).
20//! - **Git-branch** — writes buffer in memory, commit produces a real
21//! git commit on the per-mem branch with the trailer block.
22//! - **Archive** — writes return [`BackendError::Sealed`] without
23//! touching disk. Read methods return live content from inside the
24//! sealed `.mem` zip.
25
26use std::path::{Path, PathBuf};
27
28use crate::provenance::Provenance;
29use crate::storage::CommitId;
30use crate::vcs::CommitContext;
31
32/// One row of [`MemBackend::read_all_entities`]: the mem-relative
33/// path and either its bytes or the failure reading them.
34pub type EntityRead = (PathBuf, Result<Vec<u8>, BackendError>);
35
36/// The per-path form of [`MemBackend::read_all_entities`]: list, then
37/// read each path through the backend's own `read_entity`, so the
38/// pending-buffer precedence and snapshot rules of that method hold
39/// row by row. The trait default, and the route a one-walk backend
40/// falls back to while a transaction is staged.
41pub fn read_entities_one_by_one<B: MemBackend + ?Sized>(
42 backend: &B,
43) -> Result<Vec<EntityRead>, BackendError> {
44 let paths = backend.list_entities()?;
45 let mut out = Vec::with_capacity(paths.len());
46 for path in paths {
47 match backend.read_entity(&path) {
48 Ok(Some(bytes)) => out.push((path, Ok(bytes))),
49 // Listed-but-absent: list/read race. Skip silently.
50 Ok(None) => {}
51 Err(e) => out.push((path, Err(e))),
52 }
53 }
54 Ok(out)
55}
56
57/// Mem-backend trait. Implementations live next to the backend's
58/// other code (folder under `crate::storage::filesystem`; git-branch
59/// in the renamed-from-`memstead-git-branch` crate; archive under the
60/// archive read-paths in `crate::entity` once that wiring lands).
61///
62/// Methods are not split into `Read` / `Write` sub-traits because
63/// the engine's mutation paths frequently need both surfaces on the
64/// same backend handle (read current bytes, validate, write new
65/// bytes). Backends that cannot write return [`BackendError::Sealed`]
66/// from the write methods — typed and stable so callers branch on
67/// the discriminant rather than parsing a message string.
68pub trait MemBackend: Send + Sync {
69 /// Mem-relative paths of every entity-bearing file the backend
70 /// holds. Order is not specified; callers that need stable
71 /// ordering sort.
72 fn list_entities(&self) -> Result<Vec<PathBuf>, BackendError>;
73
74 /// Read raw bytes at `rel_path`. `Ok(None)` for a missing path
75 /// (idempotent reads); `Err` for IO or backend-specific failures.
76 fn read_entity(&self, rel_path: &Path) -> Result<Option<Vec<u8>>, BackendError>;
77
78 /// Does storage hold an entity at `rel_path`? A pure existence
79 /// probe — the write-time cross-mem target check's primitive
80 /// (flywheel W7/02): callers verifying a reference into a mem that
81 /// is not loaded ask storage directly instead of forcing the mem's
82 /// full load. The answer observes the same pending-buffer
83 /// precedence as [`Self::read_entity`] (a staged upsert exists, a
84 /// staged delete does not).
85 ///
86 /// The default reads the bytes and drops them — correct
87 /// everywhere, cheap nowhere. Backends with a cheaper metadata
88 /// answer override it: the folder backend asks the filesystem
89 /// (`symlink_metadata`, no open), the git-branch backend stops at
90 /// the tree entry (`lookup_entry_by_path`, never the blob read —
91 /// the public listing walk reads every blob and is the wrong
92 /// primitive for this question).
93 fn entity_exists(&self, rel_path: &Path) -> Result<bool, BackendError> {
94 Ok(self.read_entity(rel_path)?.is_some())
95 }
96
97 /// Every entity-bearing file with its bytes, in one pass — the
98 /// primitive a whole-mem load (boot, reload) asks for. One row per
99 /// listed path: `Ok(bytes)` or the per-path read failure, so a
100 /// caller can carry on past one unreadable entity; a path listed
101 /// but gone by read time is dropped (list/read race). The outer
102 /// `Err` is a listing failure. Order is not specified.
103 ///
104 /// The default walks `list_entities` and reads each path — correct
105 /// everywhere, and on a backend whose per-path read re-resolves
106 /// its snapshot it is quadratic: the git-branch backend's
107 /// `read_entity` opens the repository, peels the ref and inflates
108 /// the root tree on every call, so a 7,500-entity boot inflated a
109 /// 7,500-entry tree 7,500 times (96 % of the measured boot,
110 /// 2026-09-10). Backends with a one-walk answer override it.
111 fn read_all_entities(&self) -> Result<Vec<EntityRead>, BackendError> {
112 read_entities_one_by_one(self)
113 }
114
115 /// Does the storage location this backend names exist at all: the
116 /// branch ref, the folder, the archive file? Distinct from "holds
117 /// no entities": a mount whose branch was never created and a mount
118 /// whose branch is empty both list zero entities, and only this
119 /// probe tells them apart. Boot asks it to raise `MOUNT_UNBACKED`
120 /// with the right reason (`missing_ref` / `missing_path` versus
121 /// `empty`); before it existed, a mount pointing at a branch that
122 /// did not exist sat in the writable roster with zero entities and
123 /// no warning. The default says `true` (in-memory and test
124 /// backends have nothing to be missing).
125 fn storage_present(&self) -> Result<bool, BackendError> {
126 Ok(true)
127 }
128
129 /// Upsert `content` at `rel_path`. Pending until [`Self::commit`].
130 fn write_entity(&self, rel_path: &Path, content: &[u8]) -> Result<(), BackendError>;
131
132 /// Remove `rel_path`. Idempotent: no-op when the path is already
133 /// absent. Pending until [`Self::commit`].
134 fn delete_entity(&self, rel_path: &Path) -> Result<(), BackendError>;
135
136 /// Rename `from` to `to`. Pending until [`Self::commit`]. Errors
137 /// when `to` already exists.
138 fn move_entity(&self, from: &Path, to: &Path) -> Result<(), BackendError>;
139
140 /// Discard every pending (uncommitted) mutation, returning the
141 /// staging buffer to empty *without* producing a commit. The
142 /// transactional escape hatch for stage-then-commit callers:
143 /// the atomic `batch_update` stages each item's write into the
144 /// pending set, and when a later item fails validation it calls
145 /// this to drop the already-staged writes rather than commit a
146 /// half-applied batch. Idempotent — discarding an empty buffer
147 /// is a no-op.
148 ///
149 /// Default impl is a no-op: backends that never stage writes
150 /// (archive / any sealed backend) have no buffer to clear. The
151 /// folder and git-branch backends override to clear their
152 /// pending buffer (the git-branch backend also drops the
153 /// captured parent snapshot, symmetric with what `commit` does
154 /// on success).
155 fn discard_pending(&self) -> Result<(), BackendError> {
156 Ok(())
157 }
158
159 /// Flush pending mutations into a single commit. Returns the
160 /// resulting opaque [`CommitId`]; backends without history
161 /// return a synthetic id (UNIX-nanos + counter, hex) so callers
162 /// always get a non-empty cursor.
163 fn commit(&self, message: &str, ctx: &CommitContext<'_>) -> Result<CommitId, BackendError>;
164
165 /// Commit pending mutations with a parent-ref pinning guard.
166 /// When `expected_parent` is `Some`, the backend MUST refuse the
167 /// commit (`Err(BackendError::ParentMismatch { ... })`) if its
168 /// current head no longer matches the supplied ref — a sibling
169 /// writer advanced the on-disk state between the snapshot the
170 /// caller pinned and now. When `expected_parent` is `None`, the
171 /// call is equivalent to [`Self::commit`].
172 ///
173 /// Used by atomic multi-file mutations (notably the planned
174 /// referrer-rewriting rename) to surface drift mid-operation
175 /// rather than between operations. Backends without history
176 /// (folder, archive) inherit the default impl: they ignore
177 /// `expected_parent` because there's no concept of a parent to
178 /// pin against — drift detection on those mounts is a no-op
179 /// today and stays a no-op here. The git-branch backend
180 /// overrides to check the per-mem branch tip and surfaces
181 /// the mismatch with a typed error the engine layer can map to
182 /// `MEM_RELOADED` / `RENAME_PARTIAL_FAILURE`.
183 ///
184 /// Default impl: ignore `expected_parent` and delegate to
185 /// [`Self::commit`]. Bisect-safe — existing callers using
186 /// `Self::commit` directly are unaffected.
187 fn commit_with_expected_parent(
188 &self,
189 message: &str,
190 ctx: &CommitContext<'_>,
191 _expected_parent: Option<&str>,
192 ) -> Result<CommitId, BackendError> {
193 self.commit(message, ctx)
194 }
195
196 /// Append a [`Provenance`] record to the backend's mutation log.
197 /// Persistence form differs per backend — JSONL line, commit
198 /// trailer, etc. — but the in-memory shape is identical.
199 fn append_provenance(&self, record: &Provenance) -> Result<(), BackendError>;
200
201 /// Read provenance entries since `cursor` (opaque,
202 /// backend-defined: a commit SHA for git-branch, an RFC-3339
203 /// timestamp for folder, ignored for archive). `None` cursor
204 /// means "from the beginning".
205 fn read_provenance(&self, cursor: Option<&str>) -> Result<Vec<Provenance>, BackendError>;
206
207 /// Opaque cursor pointing at the backend's current state. The
208 /// engine compares against a per-mount cached cursor to detect
209 /// drift — a sibling writer (another `Engine` instance, an
210 /// out-of-band `git pull`, etc.) advancing the on-disk state past
211 /// what the engine last read. Backends without history (folder,
212 /// archive) inherit the default impl returning `Ok(None)`; the
213 /// engine treats `None` as "no drift signal available" and skips
214 /// drift detection for that mount. The git-branch backend
215 /// overrides to return the per-mem branch tip's commit SHA hex;
216 /// the filesystem backend overrides to return the changelog's
217 /// last-line timestamp cursor (folder mems with no changelog yet
218 /// keep `None`). Archive and in-memory backends stay on the
219 /// default.
220 ///
221 /// Returning `Err` is reserved for backend-internal failures
222 /// (refdb hiccup, archive read failure, etc.); the engine logs
223 /// the error and treats it as a transient None — drift detection
224 /// is best-effort and never blocks the read it accompanies.
225 fn current_head(&self) -> Result<Option<String>, BackendError> {
226 Ok(None)
227 }
228
229 /// Read the per-mem `.memstead/config.json` payload, if any.
230 ///
231 /// Returns the raw bytes the backend has for the mem's
232 /// config. The engine parses via
233 /// [`memstead_schema::config::parse_mem_config`] and stores the
234 /// result on the [`crate::Engine::mem_config_for`] accessor.
235 ///
236 /// Default impl returns `Ok(None)` — backends that don't
237 /// surface a config (or haven't yet implemented this primitive)
238 /// inherit and signal "no config available". The engine
239 /// treats `None` the same as a parse failure: `mem_config_for`
240 /// returns `None` for the affected mem, and consumers
241 /// (`memstead_health { include_config: true }`) emit empty
242 /// `writeGuidance` + `extra` blocks for that mem.
243 ///
244 /// Mirrors the pattern of [`Self::current_head`] —
245 /// backend-internal capability with a sensible no-op default.
246 ///
247 /// Implementations:
248 /// - Folder backend reads `<root>/.memstead/config.json`.
249 /// - Archive backend reads `.memstead/config.json` from inside the
250 /// zip.
251 /// - Git-branch backend reads `__MEMSTEAD:mems/<mem>/config.json`.
252 fn read_mem_config(&self) -> Result<Option<Vec<u8>>, BackendError> {
253 Ok(None)
254 }
255
256 /// Read the optional authoring-provenance payload
257 /// (`.memstead/provenance.json`) the archive carries, if any.
258 ///
259 /// Returns the raw bytes the engine parses into a
260 /// [`memstead_schema::ArchiveProvenance`] and surfaces via
261 /// [`crate::Engine::archive_provenance_for`]. Default impl returns
262 /// `Ok(None)` — a backend with no provenance member (a pre-provenance
263 /// archive, the folder/git-branch backends until their read paths
264 /// lift) inherits and signals "provenance absent". Mirrors
265 /// [`Self::read_mem_config`].
266 fn read_archive_provenance(&self) -> Result<Option<Vec<u8>>, BackendError> {
267 Ok(None)
268 }
269
270 /// Read the optional sealed check-records member
271 /// (`.memstead/checks.json`) the archive carries, if any.
272 ///
273 /// Returns the raw bytes the engine parses into a
274 /// [`crate::check::SealedChecks`] and derives check state from on an
275 /// archive mount ([`crate::Engine::archive_checks_for`]). Default
276 /// impl returns `Ok(None)`: a writable backend never carries the
277 /// member (its check state lives in the workspace ledger), and an
278 /// archive sealed without records signals "no records sealed".
279 fn read_archive_checks(&self) -> Result<Option<Vec<u8>>, BackendError> {
280 Ok(None)
281 }
282
283 /// Read the engine-owned proposal record
284 /// ([`crate::ops::proposal::PROPOSAL_RECORD_PATH`]) bytes, if any:
285 /// the sidecar a proposal merge writes on the target branch, keyed
286 /// by proposal id with every disposition. The default reads the
287 /// path through [`Self::read_entity`], which is the git-branch
288 /// backend's tree read; the archive backend overrides to read the
289 /// sealed member. `Ok(None)` for a mem no proposal was ever merged
290 /// into.
291 fn read_proposal_record(&self) -> Result<Option<Vec<u8>>, BackendError> {
292 self.read_entity(Path::new(crate::ops::proposal::PROPOSAL_RECORD_PATH))
293 }
294
295 /// Write the per-mem `.memstead/config.json` payload. Symmetric
296 /// counterpart to [`Self::read_mem_config`].
297 ///
298 /// Backends that cannot persist a config (today: archive)
299 /// inherit the default and return [`BackendError::Sealed`]. The
300 /// engine's create / migrate paths branch on the discriminant
301 /// before calling.
302 ///
303 /// Implementations:
304 /// - Folder backend writes `<root>/.memstead/config.json` to disk.
305 /// - Git-branch backend writes
306 /// `__MEMSTEAD:mems/<mem>/config.json` (workspace-level ref) —
307 /// its own commit, separate from any per-mem-branch
308 /// mutation.
309 /// - Archive backend returns [`BackendError::Sealed`] — sealed
310 /// archives never re-write configs.
311 ///
312 /// Mirrors the symmetry pattern of
313 /// [`Self::read_entity`] / [`Self::write_entity`]: the trait
314 /// surface stays balanced so the engine doesn't branch on
315 /// backend type for write paths.
316 fn write_mem_config(
317 &self,
318 _bytes: &[u8],
319 _ctx: &crate::vcs::CommitContext<'_>,
320 ) -> Result<(), BackendError> {
321 Err(BackendError::Sealed)
322 }
323
324 /// Compare-and-set the mem config: write `bytes` only if the stored
325 /// config is still byte-identical to `expected`. Returns `false` without
326 /// writing when it is not, so the caller can re-read, re-apply, and retry.
327 ///
328 /// WHY the trait carries this rather than the engine doing read-then-write
329 /// itself: on the git-branch backend the ref update already lands under a
330 /// compare-and-set against the observed tip, so a sibling's commit
331 /// survives. The folder backend had no such protection, and a plain
332 /// `fs::write` between another writer's read and its write is silent loss
333 /// with no history to recover from.
334 /// Closing that needs the check and the write to be one indivisible step,
335 /// which only the backend can arrange.
336 ///
337 /// `expected` of `None` means "write unconditionally" (a mem that has no
338 /// stored config yet). The default implementation delegates to the
339 /// note-carrying write and reports success, which is correct for backends
340 /// whose write is already atomic against concurrent writers.
341 fn write_mem_config_cas(
342 &self,
343 _expected: Option<&[u8]>,
344 bytes: &[u8],
345 ctx: &crate::vcs::CommitContext<'_>,
346 ) -> Result<bool, BackendError> {
347 self.write_mem_config(bytes, ctx)?;
348 Ok(true)
349 }
350
351 /// Record provenance for a pipeline-config edit (mediums / facets /
352 /// projections / ingests). The canonical pipeline config is a plain
353 /// JSON file under `.memstead/` on the workspace root — it has no
354 /// commit of its own — so backends with a commit timeline mirror the
355 /// edit into their provenance record; the commit is the audit trail,
356 /// the disk file stays the read path.
357 ///
358 /// `edits`: `(config_name, Some(bytes))` upserts the mirrored blob,
359 /// `(config_name, None)` removes it (a rename passes both). `kind`
360 /// is the primitive's plural (`mediums`, `facets`, `projections`,
361 /// `ingests`); `verb` names the operation for the commit subject.
362 ///
363 /// The default is a successful no-op: folder and archive backends
364 /// have no commit timeline, so the note is accepted and dropped —
365 /// the same posture as [`Self::write_mem_config_with_note`]. The
366 /// git-branch backend overrides this to commit the mirror under
367 /// `__MEMSTEAD:pipeline/<kind>/<mem>/<name>.json` with `note` on
368 /// the commit body.
369 fn record_pipeline_edit(
370 &self,
371 _kind: &str,
372 _edits: &[(String, Option<Vec<u8>>)],
373 _ctx: &crate::vcs::CommitContext<'_>,
374 _verb: &str,
375 ) -> Result<(), BackendError> {
376 Ok(())
377 }
378
379 /// Read the engine-owned anchors sidecar
380 /// ([`crate::anchor::ANCHOR_SIDECAR_PATH`]) bytes, if any.
381 ///
382 /// The sidecar lives on the mem branch under the `.memstead/`
383 /// umbrella every external reader already filters, so it never
384 /// surfaces as an entity. Returns the raw bytes the engine parses via
385 /// [`crate::anchor::AnchorSidecar::from_bytes`]; `Ok(None)` for a mem
386 /// that has never written anchors.
387 ///
388 /// Default impl returns `Ok(None)` — a backend that does not persist
389 /// anchors (a pre-anchor archive, any read-only mount) inherits and
390 /// signals "no anchors". Mirrors [`Self::read_mem_config`]. The
391 /// git-branch and in-memory backends override to read the sidecar
392 /// from their store (pending-buffer precedence, so a staged sidecar
393 /// write is visible before its commit).
394 fn read_anchors_sidecar(&self) -> Result<Option<Vec<u8>>, BackendError> {
395 Ok(None)
396 }
397
398 /// Stage a write of the engine-owned anchors sidecar so it rides the
399 /// **same commit** as the entity mutation that produced it — the
400 /// atomicity guarantee anchors depend on (rename's referrer-rewrite,
401 /// delete's anchor removal, and branch_reset's rewind all move
402 /// entity + anchor state together).
403 ///
404 /// Pending until the next [`Self::commit`] — callers stage the entity
405 /// write, then the sidecar write, then commit once. Backends that
406 /// cannot persist anchors (archive / any sealed backend) inherit the
407 /// default returning [`BackendError::Sealed`]; the engine's write
408 /// path branches on mount capability before calling. The git-branch
409 /// and in-memory backends override to buffer the sidecar under
410 /// [`crate::anchor::ANCHOR_SIDECAR_PATH`] in the same pending set the
411 /// entity write used.
412 fn write_anchors_sidecar(&self, _bytes: &[u8]) -> Result<(), BackendError> {
413 Err(BackendError::Sealed)
414 }
415
416 /// Drop every backend-side artifact for this mem — the
417 /// symmetric counterpart to the writes performed by
418 /// `memstead_mem_create` (entity-seed commit on the per-mem
419 /// branch + [`Self::write_mem_config`] on `__MEMSTEAD`). Called by
420 /// `memstead_mem_delete` orchestration when `delete_files=true` and
421 /// the delete rule matched, to give the backend a chance to
422 /// prune ref-store state the engine alone has the git authority
423 /// to touch.
424 ///
425 /// Idempotent: safe to call on a backend whose artifacts already
426 /// went away (a sibling engine pruned them, the branch was
427 /// deleted manually, etc.). The default impl returns `Ok(())` —
428 /// backends whose on-disk state is fully captured by the mem
429 /// directory (folder, archive) inherit the no-op. The
430 /// orchestrator handles its `remove_dir_all` separately at the
431 /// outer layer.
432 ///
433 /// `ctx` is the deletion's commit context — actor, client, tool,
434 /// the agent-authored note, role and identity — so the one commit
435 /// a deletion produces carries the same provenance every other
436 /// mutation's commit carries. A backend that produces no commit
437 /// ignores it.
438 ///
439 /// Implementations:
440 /// - Folder backend keeps the default — its disk state is the
441 /// mem directory, which the orchestrator rmdirs.
442 /// - Archive backend keeps the default — sealed archives have
443 /// nothing additional to prune.
444 /// - Git-branch backend deletes `refs/heads/<branch_leaf>` and
445 /// commits a tree edit on `refs/heads/__MEMSTEAD` that removes
446 /// `mems/<branch_leaf>/config.json`, with `ctx` formatted into
447 /// the prune commit's message. `<branch_leaf>` is the mem's
448 /// full hierarchical path (e.g. `planning/plan-q4-revamp` or
449 /// the bare `<name>` for flat layouts).
450 fn delete_artifacts(&self, ctx: &crate::vcs::CommitContext<'_>) -> Result<(), BackendError> {
451 let _ = ctx;
452 Ok(())
453 }
454}
455
456/// Errors surfaced by [`MemBackend`].
457///
458/// The `Sealed` variant is the typed read-only signal — backends
459/// that physically cannot write (archive) return it from every
460/// mutating method. Callers (the engine's mutation pipeline) branch
461/// on the discriminant before reaching the backend; a `Sealed`
462/// reaching this layer is a programming error in the upstream
463/// capability check.
464#[derive(Debug, thiserror::Error)]
465pub enum BackendError {
466 /// Backend physically rejects writes. Returned by the archive
467 /// backend and any future read-only backend (e.g. registry pin).
468 #[error("backend is sealed (writes rejected)")]
469 Sealed,
470 /// Filesystem IO failure.
471 #[error("backend io error: {0}")]
472 Io(#[from] std::io::Error),
473 /// Commit-time CAS conflict: the backend snapshotted parent commit
474 /// `X` at write time, but by commit time the underlying store has
475 /// advanced to `current`. Raised by backends that perform
476 /// commit-tip CAS (the git-tree backend); the engine maps it onto
477 /// its `HashMismatch` envelope so agents see one `HASH_MISMATCH`
478 /// code whether the conflict was detected at the entity-hash level
479 /// or at the commit level.
480 #[error("backend cas conflict: current commit is now {current}")]
481 HashMismatch {
482 /// New commit identifier observed when the CAS check failed.
483 /// Opaque to base callers; the git-tree backend populates it
484 /// with a hex commit object id.
485 current: CommitId,
486 },
487 /// Path-related rejection that does not map onto the IO case:
488 /// an empty relative path, a path that escapes the mem root, a
489 /// move whose source is missing or whose target is already pending.
490 #[error("backend path error: {0}")]
491 Path(String),
492 /// Backend-specific failure not modelled by the variants above.
493 /// Carries an agent-readable message; structured backend errors
494 /// add their own variant.
495 #[error("backend error: {0}")]
496 Other(String),
497 /// Parent-ref pinning guard tripped on
498 /// [`MemBackend::commit_with_expected_parent`] — the backend's
499 /// current head no longer matches the caller's `expected_parent`.
500 /// A sibling writer (another `Engine` instance, an out-of-band
501 /// `git pull`, a manual git operation) advanced the on-disk state
502 /// between the snapshot the caller pinned and now. The engine
503 /// layer maps this into `MEM_RELOADED` /
504 /// `RENAME_PARTIAL_FAILURE` depending on whether other mems
505 /// already committed in the same logical operation. Today only
506 /// the git-branch backend (planned override) produces this
507 /// variant; folder and archive backends inherit the default impl
508 /// of `commit_with_expected_parent` which delegates to `commit`
509 /// without parent checking.
510 #[error(
511 "parent-ref mismatch: expected {expected}, found {actual} — sibling writer advanced the mem"
512 )]
513 ParentMismatch { expected: String, actual: String },
514}