Skip to content

feat: lock-file identity, bounded-wait acquisition, and Busy diagnostics#25

Merged
murari316 merged 8 commits into
intuit:mainfrom
pradeepmouli:feat/lockfile-identity-upstream
Jul 22, 2026
Merged

feat: lock-file identity, bounded-wait acquisition, and Busy diagnostics#25
murari316 merged 8 commits into
intuit:mainfrom
pradeepmouli:feat/lockfile-identity-upstream

Conversation

@pradeepmouli

Copy link
Copy Markdown
Contributor

What

  • New infigraph-core::lockfile module: JSON identity payload (pid / role / build_hash / acquired_at) stamped into held lock files; bounded-wait acquisition with 1ms→500ms exponential backoff; a structured Busy error naming the current holder; conservative stale handling — the kernel flock is the liveness truth (a free flock with a leftover payload is adopted; a held flock with an unreadable payload is an unknown holder and is never broken).
  • WriteLock (the graph write lock at <db>.lock) now delegates to it. Public API unchanged; behavioral change: write_lock() waits up to 30s and then errors with a downcastable Busy instead of blocking forever. New GraphStore::write_lock_with_timeout for caller-chosen budgets.
  • Compile-time build hash (build.rsINFIGRAPH_BUILD_HASH, git-dir-aware rerun tracking) so a stale-binary lock holder is identifiable from the lock file alone.

Why

Today the graph write lock is a 0-byte flock: a wedged or orphaned holder hangs every other process silently and undiagnosably. This makes contention observable (who holds it, since when, built from what) and bounded (structured timeout errors instead of infinite blocks). It is groundwork for follow-up PRs adding an operation-scoped index lock and shared-state (sessions/registry) locking.

Compatibility

  • flock semantics unchanged — old and new binaries interoperate on the same lock files; an old binary's bare flock is reported as "unknown holder" and never broken.
  • All existing call sites compile unchanged; the pre-existing write_lock{,_edge_cases,_wiring,_perf} suites pass unmodified.

Testing

  • 15 new unit/integration tests (identity stamping, stale adoption, bounded-wait timeout with holder naming, unknown-holder conservatism, cross-handle contention), written TDD.
  • Full infigraph-core suite green: 29 suites, 589 passed, 0 failed.
  • Contended-throughput perf check (ignored/manual test): 3/3 runs within threshold.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GhPBkDMHPpgcYJ3TKLAC1r

pradeepmouli and others added 7 commits July 20, 2026 19:36
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

# Conflicts:
#	crates/infigraph-core/src/lib.rs
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…doption

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… Busy on expiry)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…rnel-flock throughput

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@murari316 murari316 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed diff in full — lockfile.rs is well-structured (flock as liveness truth, identity payload for diagnostics only, bounded-wait exponential backoff, Busy error naming holder). 12 new tests cover identity roundtrip, stale-payload adoption, timeout naming, and old-binary compatibility. Approving.

@murari316
murari316 merged commit 75e5f17 into intuit:main Jul 22, 2026
1 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants