Skip to content

[zed-lock] Extract event-driven cross-platform process locking into a standalone crate #180

Open

Description

@ORESoftware

Objective

Complete github.com/zed-pkg/zed-lock as the canonical runtime-neutral Rust library for local cross-process file locking and migrate zed-cli without weakening recursive-install, immutable-store, transaction, or recovery contracts.

Canonical Linear issue: DEN-2076
Canonical Linear architecture: zed-lock event-driven cross-platform locking architecture
Canonical GitHub architecture: zed-docs document 31

Landed library baseline

  • zed-pkg/zed-lock repository and crate exist.
  • Kernel-backed blocking/evented architecture is implemented.
  • Linux, macOS, and Windows fixed-OS conformance exists.
  • Descriptor/handle non-inheritance regression landed through zed-pkg/zed-lock#5; current evidence commit: f8add411c28c888a28abdcbc7fa9dcdb5ba0e745.
  • Independent inheritance certification landed in zed-pkg-test/concurrent-install-locking#11.

Current zed-cli migration

Draft PR zed-pkg/zed-cli#246 migrates the remaining four direct fs2 owners and removes the direct manifest dependency.

Exact candidate:

base 0ecd5b00cdd4c5df66824bd9ffdeb079b592a651
head 7897b7f82df13729672c4b12dbb7934ed47a024a

Exact six-file boundary:

  • Cargo.lock
  • Cargo.toml
  • src/auth.rs
  • src/global.rs
  • src/install_graph.rs
  • src/managed_install.rs

The candidate has 24/24 green product workflows and independent Windows Server 2025 certification:

  • run 31272111594
  • artifact 9025997603
  • digest sha256:f2dd3a4c5adc14d204d0df6154f69ceb327bab125634bfb18f1ee277d8df6344

The independent run proved every excluded Windows test on unchanged main before passing the candidate's locked all-target build, all remaining tests including process locks, and strict Clippy.

Serial promotion gate

Do not merge #246 yet. It is intentionally draft and serially blocked behind:

  • zed-pkg/zed-cli#131
  • zed-pkg-test/zed-pkg-e2e#49

After that predecessor lands, #246 must be semantically rebased, retain only its intended migration, and rerun complete exact-head product plus independent certification.

Proven separate baseline defects

The Windows attribution work created focused, non-lock-regression trackers:

  • zed-pkg/zed-cli#249 — self-update executable replacement baseline;
  • zed-pkg/zed-cli#252 / Linear DEN-3090 — symlink-dependent E2E tests must certify Windows copy mode;
  • zed-pkg/zed-cli#253 / Linear DEN-3097 — frozen remote file: authority rejection must be stable and redacted cross-platform.

Remaining zed-lock security hardening

zed-pkg/zed-lock#6 / Linear DEN-3091 owns private lock-directory/file permissions or ACLs, symlink/reparse-resistant rendezvous opening, race-resistant path validation, and unsafe-existing-path errors. This remains separate from #246.

AI-agent bridge

Immutable exact-SHA adversarial review packets are queued on ORESoftware/ai-agent-bridge.rs#104. Provider execution remains unavailable because of credit/plan exhaustion, so no live AI-agent approval is claimed.

Remaining acceptance criteria

  • Standalone repository/crate exists and builds without a Zed-registry bootstrap dependency.
  • Blocking, async/helper-thread, and explicit immediate acquisition APIs exist.
  • Cross-platform process/crash/non-inheritance conformance exists.
  • Remaining direct zed-cli lock owners are migrated in a certified exact-head candidate.
  • Declared serial predecessor lands.
  • refactor: move remaining local locks behind zed-lock #246 is rebased and fully recertified on the resulting main.
  • Secure rendezvous-opening policy in zed-lock#6 lands and is certified.
  • Final docs/releases point to immutable shipped commits and evidence.

Activity

  1. self-assigned this
    on Aug 5, 2026
  2. linear-code commented on Aug 5, 2026

    @linear-code
  3. ORESoftware commented on Aug 5, 2026

    @ORESoftware
    ContributorAuthor

    Implementation PR: #183.

    This increment creates the independently packageable crates/zed-lock workspace crate, migrates Store project/install, artifact, and build locks to it, retains compatibility re-exports, and adds bounded evented waiting, reentrancy policy, deterministic lock-set ordering, diagnostics, package/security files, examples, and cross-process conformance.

    Pre-PR Linux validation passed all crate tests, migrated Store/process tests, formatting, and strict workspace Clippy. The permanent PR workflows are now certifying Linux, macOS, and Windows.

    The issue remains open after this PR because the final history-preserving split to an actual zed-pkg/zed-lock repository, native Windows overlapped cancellation, inheritance certification, and the larger fault/soak matrix are still outstanding.

  4. ORESoftware commented on Aug 5, 2026

    @ORESoftware
    ContributorAuthor

    Merged implementation increment: #183 landed on main as 74b16a16b5d1d36d56110ccd8161aac21b175edb.

    Landed now:

    • independently packageable crates/zed-lock with Cargo and Zed package metadata, README, license, security policy, and example;
    • blocking, immediate, timeout, and runtime-neutral Future acquisition APIs;
    • one bounded dedicated waiter thread per active asynchronous native request, with no userspace lock polling;
    • deterministic reentrancy policy and class/path ordering for lock sets;
    • structured lifecycle events and diagnostics that are explicitly non-authoritative;
    • cross-process release, owner-death, isolation, and 8-process/800-increment conformance;
    • zed-cli::Store migration for project/install, artifact, and build locks;
    • isolated cargo install --locked certification with all internal path dependencies constrained to the checkout;
    • complete green Linux, macOS, Windows, Nix, general CI, policy, review, and hardening workflows.

    This issue remains open for the actual history-preserving split to github.com/zed-pkg/zed-lock, native Windows overlapped cancellation, descriptor/handle inheritance certification, filesystem capability classification, larger soak/fault injection, and migration of the remaining direct fs2 users.

  5. ORESoftware commented on Aug 5, 2026

    @ORESoftware
    ContributorAuthor

    Independent test-org coverage is now merged in zed-pkg-test/concurrent-install-locking#9 as f65fa47f5006404828e1f2bf069267bd81a1365a.

    The zed-pkg-test harness resolves the production zed-lock package from zed-pkg/zed-cli main rather than copying its implementation. Green Linux, macOS, and Windows acceptance coverage now includes:

    • twelve hot-key waiter threads while an unrelated cold key progresses;
    • non-FIFO exclusive handoffs and waiter-permit cleanup;
    • sharded protected thread counters;
    • one-native-request timeout observation;
    • cancellation followed by late acquire/immediate release;
    • deterministic lock-class/path ordering and duplicate canonical identity rejection;
    • Unix symlink alias contention;
    • six-process exclusive critical-section handoff;
    • killed-owner recovery with stable rendezvous-file retention;
    • unrelated process-lock concurrency;
    • ten-process protected-counter contention.

    A scheduled/manual release-mode soak expands this to 48 threads, 20 processes, 12 shards, and thousands of protected acquisitions. The broader inheritance, filesystem-capability, and transaction-boundary fault matrix remains open.

  6. ORESoftware commented on Aug 5, 2026

    @ORESoftware
    ContributorAuthor

    Standalone publication is complete.

    Shipped repository and release:

    Repository CI is green on Ubuntu, macOS, and Windows for formatting, all-target tests, and strict Clippy. zed-pkg/zed-lock#1 merged the self-publishing workflow.

    Independent immutable evidence:

    • zed-pkg-test/concurrent-install-locking#10 merged as aeb181db48cc38fec9ff7fcf09b8c0194a293a5b.
    • The harness now pins zed-pkg/zed-lock at exact commit 0fc100afc3cd60b5ce091b4207f910bf08f2cfb7 rather than importing the in-tree package from a mutable zed-cli branch.
    • Harness CI and the full Ubuntu/macOS/Windows contention, crash, timeout, cancellation, aliasing, ordering, and protected-counter matrix passed unchanged.

    Security cleanup performed during publication: an incorrectly generated initial workflow expanded an ephemeral Actions expression. The invalid run was deleted and the public repository root history was rewritten to a clean parentless commit before PR #1; the current history and workflow contain no embedded token.

    This issue remains open for the still-unfinished acceptance items: descriptor/handle inheritance certification, deeper Windows overlapped cancellation, NFS/SMB capability classification, remaining direct lock-user migration, and the larger mutation/fault-injection matrix.

  7. ORESoftware commented on Aug 5, 2026

    @ORESoftware
    ContributorAuthor

    The standalone repository split and CLI consumption are now complete.

    Final migration:

    • zed-pkg/zed-cli#198 merged as 506106798e3fb3d23804f544dd41b020e9f7f8df.
    • zed-cli now pins zed-pkg/zed-lock@0fc100afc3cd60b5ce091b4207f910bf08f2cfb7 in both Cargo.toml and generated Cargo.lock.
    • The duplicate crates/zed-lock workspace package is removed.
    • CLI workflows now verify the immutable standalone dependency and retain only project/Store/recursive integration coverage; crate-level conformance and release ownership live in zed-pkg/zed-lock.
    • The isolated cargo install --locked path verifies the same immutable source and asserts the in-tree copy is absent.

    Pre-merge validation performed by the authenticated control runner passed formatting, all Store tests, project-lock tests, install-graph tests, evented process-lock integration, recursive HTTP concurrency, and strict Clippy for all zed-cli targets. Repository-native Linux/macOS/Windows and isolated-install jobs were also started against the merged source and had already verified the immutable dependency boundary before merge.

    The extraction/repository/publication acceptance criteria are satisfied. This issue remains open only for the broader items already moved to zed-pkg/zed-lock#3: refs/shared-metadata migration, native Windows cancellation, descriptor/handle inheritance, NFS/SMB capability classification, deeper aliasing, and expanded fault/soak evidence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions