fix: ghost-commit recovery protocol and hardening sweep#16
Merged
Conversation
Fix formatting violations flagged by `cargo fmt --check` in five files touched by the ghost-commit and hardening commits, and correct the `validate_path_safe_id` doc comment which claimed the predicate accepts `.` for UUID/timestamp IDs — it does not.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two groups of changes:
1. Ghost-commit crash recovery (
3ed9c8d) — closes the window where the materializer could crash after the trunk commit but before writingChangesetMaterialized, leaving trunk ahead of the event log.EventKind::ChangesetMaterializationStarted { parent, path }fence event, written before any git write (crates/phantom-core/src/event.rs).phantom-orchestrator/src/recovery.rsreconciles orphan fences against HEAD's first-parent chain (bounded to 128 commits) using parent-OID + author matching. Idempotent by construction.ph recoverCLI (crates/phantom-cli/src/commands/recover.rs), surfaced inph status, filterable inph log.tests/integration/tests/fence_emitted_in_order.rs,fence_survives_materialized_fault.rs).2. Hardening sweep (
4d95fd2) — correctness and security improvements, no new features:schema_versionbump now run in oneTransaction<Sqlite>so a crash between steps can't corrupt recorded version.LIKEmetacharacters (%,_,\) now escaped inapply_event_filters;QueryBuilderfields made private; typedSortDirenum replaces raw strings.mark_droppedUPDATE + snapshot DELETE now in one transaction.to_rfc3339_opts(Millis, true)for stable lexicographic sort.OverlayLayerwhiteout persistence errors now propagate — prevents silent data loss where a stale whiteout would hide a re-created file on restart.phantom-git::fs_walk: addedMAX_DEPTH = 64and(dev, ino)symlink cycle tracking.phantom-git::test_supportnow gated behind atest-helpersfeature, kept out of the release binary.ChangesetId/AgentId/PlanIdvalidate on deserialize via#[serde(try_from = "String")]; restricted to ASCII alphanumerics + hyphen + underscore (anti-homograph).latest_event_for_changeseterrors now propagate instead of silently usingNonecausal parent, preserving the causal DAG used by rollback.overflow-checks = trueadded to release profile.release.yml: defaultcontents: read; onlypublishjob getscontents: write..github/dependabot.ymladded (weekly cargo + github-actions updates, semver-major cargo updates excluded).RwLockrecoveries useunwrap_or_else(PoisonError::into_inner).EventStoreError::SchemaCorrupted { key, value }replaces misleadingSchemaMismatchonschema_metaparse failures.3. Merge + cleanup (
4b83ceb,0797e2b) — mergedmain(picks uprand 0.8.6Dependabot bump), appliedcargo fmt, and corrected a stale docstring invalidate_path_safe_idthat claimed.was allowed (it isn't).Test plan
cargo fmt --all --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo test --workspace --all-features— 52 test binaries, 0 failuresRUSTDOCFLAGS="-Dwarnings" cargo doc --workspace --no-deps --all-featurescargo audit— no known vulnerabilitiescargo deny check— advisories / bans / licenses / sources all okCompat notes
ChangesetId/AgentId/PlanIdnow reject non-ASCII characters on deserialize. All current internal generators (UUID v7,plan-YYYYMMDD-HHMMSS) fall inside the allowed set; any pre-existing.phantom/events.dbwith non-ASCII IDs would need regeneration. No impact expected in practice.