Skip to content

[factory] Per-repo relayfile mount attempts fight a supervised mount daemon and wedge ingestion #241

Description

@khaliqgant

Summary

On every startup Factory attempts a per-repository relayfile mount for each repo in repos.names, even when the workspace already has a registered mirror. Each attempt fails, and when a supervised mount daemon is running, Factory's attempts cancel it — the two fight over one mirror until Factory itself wedges.

Evidence

Per-repo mount attempts always fail

Every Factory startup emits one of these per repo (16 on 2026-08-14):

[factory] warning: could not start relayfile mount at /Users/.../AgentWorkforce/relay:
  [factory] relayfile mount start failed (exit 1): error: workspace rw_7ccfea89 is already
  mirrored at /Users/.../AgentWorkforce/chief/.integrations; refusing to silently re-home it
  to /Users/.../AgentWorkforce/relay/.integrations.
  Pass --rehome to move the mirror there, or omit LOCAL_DIR to use the registered directory

relayfile is correct to refuse. Factory should not be asking: the workspace has a registered mirror at chief/.integrations, and that mirror is the one Factory should use.

The contention wedges Factory

com.agentworkforce.chief.integrations-mount is a KeepAlive launchd job running relayfile restart <workspace> --foreground. With that job enabled alongside Factory:

mount sync stopping: context canceled
mount sync cycle failed: context canceled
websocket read failed; falling back to polling: use of closed network connection

launchctl print showed runs = 4 within minutes — Factory cancels the daemon, KeepAlive respawns it, repeat. Factory wedged at live subscription starting and produced zero ingest cycles across two consecutive restarts. Disabling the launchd job and restarting Factory got it past the wedge immediately and ingestion resumed.

The practical consequence today: the mount daemon cannot be supervised. It died on Aug 11 15:43 and nothing restarted it for three days, because the only supervisor that would have is incompatible with Factory.

Related: id-vs-name resolution mints junk workspace entries

The canonical workspace is named default; its id is rw_7ccfea89. When a caller passes the id where a name is expected, the lookup misses and relayfile creates a fresh stub entry named after the id with no localDir, then fails with:

error: workspace rw_7ccfea89 has no recorded local mirror directory

~/.relayfile/workspaces.json had accumulated 4 entries for rw_7ccfea89 this way — one real, three stubs — producing:

warning: delegated credential workspace "rw_7ccfea89" was not uniquely resolved in
  /Users/khaliqgant/.relayfile/workspaces.json; using raw workspace shard and probing alias shards

Deduplicating to a single entry cut Factory's GitHub ensureSubRoot from 30s+ to 616ms. Factory's per-repo mount calls are one of the generators: a stub reappeared immediately after cleanup, minted by a Factory startup.

Asked-for behaviour

  1. Detect and reuse an existing mirror. Before attempting any mount, resolve the workspace's registered mirror directory; if one exists, use it. Never attempt a per-repo re-home, and never emit 16 identical failures as routine startup noise.
  2. Do not cancel a mount Factory does not own. If a mount daemon is already serving the workspace, Factory must attach to it rather than restart it out from under its supervisor.
  3. Resolve workspaces by id or name without minting on miss. A lookup miss must be an error, not a silent write that corrupts workspaces.json. (The relayfile-side half of this may belong in the relayfile repo — file a companion issue there if the fix does not sit cleanly in Factory.)

Definition of done

  • Factory starts with zero could not start relayfile mount warnings when the workspace has a registered mirror.
  • Factory runs alongside a supervised (KeepAlive) mount daemon without either cancelling the other, and reaches ingestion. Verify by enabling com.agentworkforce.chief.integrations-mount and confirming Factory gets past live subscription starting into listTree cycles.
  • A Factory startup adds no new entries to ~/.relayfile/workspaces.json.

Constraints

  • Branch from origin/main. The local checkout sits on codex/222-routed-pr-babysitter-v2 with an unrelated WIP commit (b2ad725) — do not build on it and do not disturb it.
  • mergePolicy: never. Open the PR and stop at review.
  • The launchd job is currently left disabled deliberately, because enabling it wedges Factory. Re-enabling it is part of verifying the fix, not a precondition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    factoryFactory automation triggerfactory:in-progressFactory agents are working on this issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions