← Back to Pull requests

fix(file-lock): keep the Windows holder record out of *.json scans #6164

Closed
unknown closed this pull request without merging on Oct 11, 2026 05:38 UTC
View on GitHub
unknown unknown commented on Oct 10, 2026 18:59 UTC
Author

Goal And Delivered Outcome

  • Outcome basis / optional anchor: Bug report #6128, including the root-cause comment that identifies the native chat admission crash.

  • Goal/source and gap: On Windows, lock_holder_path writes the holder record to a persistent sidecar named <file>.lock.holder.json beside the locked state file. It survives release, and scans that collect .json state records read it as state. Native chat admission (ChatExternalConversations.pending()) crashes with KeyError: 'binding_id', and Windows-only test walkers flake. POSIX keeps the record inside .lock, so Linux CI never sees it.

  • Observable before → after, with the validation row that proves it:

  • - Before: with a holder sidecar beside a request journal, the second external request admission raises KeyError: 'binding_id', and glob(".json") beside a locked file lists the sidecar.
    - After: admission succeeds and pending() lists only request journals; the Windows sidecar is <file>.lock.holder and never matches
    .json. Proven by the regression_parity rows below.
  • Issue/task and intended base: Closes #6128. Base main.
  • Author Declaration

  • Written by: model_agent (Claude Opus 5.5, Anthropic, via Claude Code), operated by @LIHUA919.
  • Implemented against

  • Specification and revision: issue #6128 and its root-cause comment (suggested direction 1: a non-.json sidecar name, plus a defensive filter in the product walker), and docs/reference/protocols/file-lock-acquisition-v0.md at base 04bd639b4.

  • Criteria:
  • | Criterion (spec clause) | Disposition | Symbol / path | Test or command |
    | --- | --- | --- | --- |
    | The Windows holder sidecar must not be named like a state file | implemented | lock_holder_path in loopx/file_lock.py | tests/test_file_lock.py::test_windows_holder_sidecar_is_not_a_json_state_file |
    | Existing installs: legacy .lock.holder.json records are migrated and still read while an older process may hold the lock | implemented | lock_holder_paths, _read_latest_holder_record, _persist_holder_record | test_windows_holder_removes_a_legacy_json_sidecar_on_acquire, test_windows_holder_reader_prefers_the_latest_acquisition |
    | Product walkers that must stay .json-shaped filter the holder name defensively (external chat requests) | implemented | ChatExternalConversations.pending | tests/test_chat_conversation_bindings.py::test_external_request_listing_ignores_lock_holder_records |
    | Lock-artifact name lists stay complete (machine-state classification, goal deletion safety check) | implemented | loopx/paths.py, loopx/control_plane/goals/deletion_service.py | existing suites listed under Validation |
    | POSIX holder layout and liveness semantics unchanged | implemented | lock_holder_liveness | test_posix_holder_liveness_reads_the_lock_file_record |
    | Patch every other
    .json walker individually | out_of_scope | — | The rename fixes them going forward; see Coverage and gaps |

  • Self-check before submission:

  • - Verified:
    - I read every lock_holder_path caller and every module that both takes exclusive_file_lock and globs .json.
    - Each new test fails on the base and passes on the head.
    - Assumed, not verified:
    - Windows behavior is simulated on Linux by giving loopx.file_lock an os proxy with name == "nt".
    - Kernel locking still uses the host backend, so msvcrt itself was not exercised.

    Scope And Continuation

  • Completed scope and remaining work: Complete within this scope.

  • Slice boundary / successor: N/A. A real native-Windows run of the two suites named in the issue would add confirmation; the reporter offered help.
  • Validation

  • Tested revision: ce95406da4b3bccd7fa69fc0923035b22fe5a9cf (the code is identical to the parent 5347064f7; the head adds only the docs commit)

  • Run state: finished

  • Input classes: synthetic
  • | Check kind | Result | Public-safe evidence / limitation |
    | --- | --- | --- |
    | regression_parity | passed | The four new tests/test_file_lock.py tests fail on base file_lock.py (three fail outright; the latest-record test guards the new two-name reader) and pass on head. |
    | regression_parity | passed | tests/test_chat_conversation_bindings.py::test_external_request_listing_ignores_lock_holder_records fails on the base with the exact KeyError: 'binding_id' from the issue, and passes on head. It exercises the real admission path with the ordinary fixture. |
    | unit | passed | Focused suites on the rebased head: test_file_lock.py, test_file_lock_cross_process.py, test_chat_conversation_bindings.py, test_collaboration_sidecar_scan.py, control_plane/test_legacy_coordination_writer_fence.py: 44 passed, 2 skipped (platform skips). |
    | unit | passed | Broader run on the pre-rebase head: all test files referencing lock_holder, deletion_service, _runtime_root_has_machine_state or external_conversations gave 665 passed, 1 failed. The failure was test_delegation_stop_nested_host.py::...[sqlite-paused] under -n 4 load; it passed 3/3 serial runs on the head and 3/3 on the base, so it is unrelated. |
    | static | passed | ruff on changed files; mypy (configured strict set); git diff --check; scripts/generate_semantic_inventory.py --changed-from HEAD found no new vocabulary carriers. |
    | static | passed | loopx canary premerge --from-git-diff: risk-profile smokes 8/8 and the public boundary scan passed. Its semantic-vocabulary-drift-smoke initially flagged stale line numbers in project_registry_io_manifest_v1.json; this PR regenerates the manifest (two paths.py line shifts, no classification change) and the smoke now passes. I did not rerun the full premerge command after regenerating. |
    | real_entrypoint | not_run | No native Windows host was available. |

  • Coverage and gaps:

  • - The rename closes the whole class going forward for every
    .json walker. Older Windows installs keep one legacy record per lock until that lock is next acquired; external chat admission filters it explicitly.
    - Mixed-version upgrade window: an older process does not see the new name, so its diagnostics report absent for records written by a newer process. Holder records are advisory, and the kernel lock stays authoritative.
    - Legacy cleanup is best-effort: an OSError leaves the record for the next holder.

    Frontend / Visual Evidence

  • UI impact: none

  • Before: N/A

  • After: N/A

  • States and viewports shown: N/A

  • Source data: none

  • Attention review: N/A, no UI change.
  • Type of Change

  • Bug fix

  • New feature

  • Breaking change

  • Refactoring (no functional changes)

  • Documentation update

  • Test update
  • LoopX Area

  • Control plane (goals, todos, quota, scheduler, registry, runtime)

  • Benchmark boundary (adapters, runners, verifiers, scoring, evidence)

  • Capability or extension (providers, adapters, skills)

  • Public docs or presentation surface (README, protocols, dashboard)

  • Build, packaging, installer, or CI

  • Host or runtime integration
  • Technical Direction

  • Direction / acceptance reference, when applicable: Core control-plane hardening (Windows runtime correctness).
  • Shared-authority RFC fixture impact

    N/A. This PR makes no claim against the TypeScript migration or shared Goal Authority RFCs.

    Boundary Checklist

  • Neither the diff nor this PR body/comments/attachments disclose private state, credentials, raw traces or verifier output, internal links, or local machine paths (including .loopx/, .codex/goals/, and live ACTIVE_GOAL_STATE.md).

  • I did not duplicate maintainer-owned benchmark work unless a maintainer split out a public issue for it.

  • I kept the change scoped to the linked issue/task.

  • I completed the visual evidence section for UI changes, or marked UI impact none.

  • Every commit includes a DCO Signed-off-by trailer (git commit -s).
  • Future-facing pass: applied. lock_holder_paths gives the two name-list owners (paths.py, deletion_service.py) one helper instead of hand-spelled names. I considered and deferred a shared state-directory walk helper across all .json walkers, because the rename removes the hazard for them.

    Changes runtime behavior of loopx/*, so this is left for maintainer review and merge.

    🤖 Generated with Claude Code

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: BigDataDZ Review duration: 639m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #6164"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%