Skip to content

Save the repositories folder alone; never leave an empty agent storage lock (0.3.17) - #29

Merged
MainSequenceDev merged 2 commits into
mainfrom
claude/shared-folder
Nov 5, 2026
Merged

MainSequenceDev merged 2 commits into
mainfrom
claude/shared-folder

Conversation

@MainSequenceDev

@MainSequenceDev MainSequenceDev commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Why

Repositories folder. Claude Desktop keeps its own copy of the repositories folder. Codex and the mainsequence CLI share mainsequence_path in the CLI's config.json. Changing the folder in one tool doesn't reach the others. To unify them, Claude needs to save just the folder into the shared file and to know whether the file already names one.

Agent storage lock. CI failed once on this branch in a process killed after send leaves an uncertain record, with STORE_ERROR after the store's 3-second lock wait. The same commit passed in the other run. The cause is in the store:

  • The lock file was created empty and its owner written afterwards.
  • wait takes the lock every 250 ms while a send runs.
  • A process killed between those two steps left an empty lock, which is never reclaimed by design.
  • Every later call then failed with "Saved agent requests could not be read safely" until someone deleted the file by hand.

What changes

  • writeWorkspacePreferences({ backend?, baseDir?, commandCenterUrl? }) saves only the fields it is given and keeps every other setting. A call with none is refused. The Codex plugin passes all three, so its behaviour is unchanged.
  • readWorkspacePreferences also returns baseDirSaved: true when the folder comes from the shared configuration rather than the <home>/mainsequence default.
  • The agent store's lock is created with its owner already in it. The owner record is written to a private file, which is then linked into place; the link fails while another lock exists.
    • A process killed at any moment leaves either no lock, or a lock naming a dead owner, which the next call reclaims.
    • An owner killed between linking and cleaning up leaves its private file behind; that file is removed during reclamation.
    • An empty lock left by an older version is removed once it is ten seconds old, under a durable claim. A new empty lock is still waited for, because its owner may still be writing.

Verification

npm run release:check passes: 189 tests, plus the docs and package checks. New tests:

  • { baseDir } is saved alone, baseDirSaved is reported both ways, and an empty call is refused.
  • A dead owner's lock that still has its second name is reclaimed.
  • A fresh empty lock is waited for, then refused; a stale one is removed.

The killed-process test passed 30 times in a row.

🤖 Generated with Claude Code

MainSequenceDev and others added 2 commits November 5, 2026 14:22
So Claude Desktop, the Codex plugin and the mainsequence CLI can keep one repositories
folder: the CLI's `mainsequence_path` in its config.json.

- `writeWorkspacePreferences({ backend?, baseDir?, commandCenterUrl? })` saves only the
  fields given and keeps every other setting. A call with none is refused. The Codex
  plugin still passes all three, so it behaves as before.
- `readWorkspacePreferences` also returns `baseDirSaved`: true when the folder comes
  from the shared configuration rather than the `<home>/mainsequence` default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CI failed once on this branch in `a process killed after send leaves an uncertain record`
(STORE_ERROR after the 3-second lock wait); the same commit passed in the other run. The
cause is in the store, not the test: the lock was created empty and its owner written
after, and `wait` takes it every 250 ms while a send runs. A process killed between the
two left an empty lock, which by design is never reclaimed, so every later call failed
with "Saved agent requests could not be read safely" until the file was removed by hand.

- The owner record is written to a private file first and linked into place, which fails
  while another lock exists, so the lock never exists without its owner. A lock left with
  that second name by an owner killed between linking and cleaning up is reclaimed with
  the dead owner's lock, as before.
- An empty lock (left by an older version) is removed once it is ten seconds old, under a
  durable claim; a new one is still waited for, since its owner may be writing.

Tests: a dead owner's lock with its second name is reclaimed; a fresh empty lock is waited
for and refused, a stale one removed. The killed-process test passed 30 times in a row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MainSequenceDev MainSequenceDev changed the title Save the repositories folder alone into the shared settings (0.3.17) Save the repositories folder alone; never leave an empty agent storage lock (0.3.17) Nov 5, 2026
@MainSequenceDev
MainSequenceDev merged commit b010147 into main Nov 5, 2026
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.

1 participant