Skip to content

fix(core): simplify directory lock fallback safety#27

Merged
iam-brain merged 4 commits into
mainfrom
iam-brain/lockfile-fallback-smoke
Apr 7, 2026
Merged

fix(core): simplify directory lock fallback safety#27
iam-brain merged 4 commits into
mainfrom
iam-brain/lockfile-fallback-smoke

Conversation

@iam-brain
Copy link
Copy Markdown
Owner

@iam-brain iam-brain commented Apr 6, 2026

Summary

  • keep the proper-lockfile import-shape fix so the plugin can load when the package resolves as a CommonJS-style namespace
  • simplify the directory fallback to retry-only locking with owner metadata used only for safe release
  • replace the stale-window and heartbeat coverage with focused regressions around plugin loading and fallback lock safety

Root Cause

The plugin auth flow was not failing inside the auth menu first. It was failing earlier while loading the plugin because proper-lockfile did not expose an ESM default in this environment. The first lockfile patch fixed that loader mismatch, but the later fallback work introduced race-prone stale-reclaim behavior that was riskier than the original problem.

What Changed

lib/cache-lock.ts

  • resolve proper-lockfile from both direct and namespace-shaped module exports
  • keep a conservative directory-lock fallback when the import is unavailable
  • write an owner token only so release() can avoid deleting a replacement lock
  • remove stale reaping and heartbeat behavior from the fallback path

test/cache-lock.test.ts

  • add a plugin-entry regression that imports ../index with a CommonJS-style proper-lockfile shape
  • cover retry-only fallback behavior, owner-write cleanup, replacement-lock release safety, and no-stale-reap exclusivity

Validation

  • npm run verify
  • opencode auth login --print-logs
    • plugin loaded from /Users/bryanfont/Projects/iam-brain/opencode-openai-multi/dist/index.js
    • reached the provider picker without the previous proper-lockfile load failure

Follow-up

The earlier TTY auth investigation is still preserved in stash for the separate follow-up PR.

ramhaidar and others added 4 commits April 6, 2026 16:04
- Use a bundled directory-based lock when proper-lockfile cannot be resolved so cache locking still works in packaged/runtime environments.
- Target: core
@iam-brain iam-brain changed the title fix(core): keep directory lock fallback alive under stale windows fix(core): simplify directory lock fallback safety Apr 6, 2026
@iam-brain iam-brain marked this pull request as ready for review April 7, 2026 13:09
@iam-brain iam-brain merged commit aecf3b9 into main Apr 7, 2026
5 checks passed
@iam-brain iam-brain deleted the iam-brain/lockfile-fallback-smoke branch April 7, 2026 13:10
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