Skip to content

A2-1: Wire ClusterManager into Adapter and FileSystem #139

Closed

Description

@scttfrdmn

Context

The distributed layer (internal/distributed/ClusterManager) is completely disconnected from the running application. internal/adapter/adapter.go never instantiates it. internal/fuse/filesystem.go's FileSystem struct has no coordinator field. As a result, all the distributed infrastructure built in v0.11.0 has no effect on actual filesystem operations.

What to implement

internal/fuse/filesystem.go:
Add coordinator types.DistributedCoordinator field to FileSystem struct. Default is nil — when nil, all existing code paths are completely unchanged (zero overhead, zero behavior change for single-node users).

Add a WithCoordinator(coord types.DistributedCoordinator) mount option function that sets this field.

internal/adapter/adapter.go:
Add clusterMgr *distributed.ClusterManager field to Adapter struct.

In Adapter.Start(), after the backend and cache are initialized, check a.config.Cluster.Enabled. If true:

  1. Construct distributed.NewClusterManager(&a.config.Cluster)
  2. Call cm.SetBackend(a.backend) and cm.SetCache(a.cache)
  3. Call cm.Start(ctx)
  4. Store as a.clusterMgr
  5. Pass fuse.WithCoordinator(cm.GetCoordinator()) when creating the mount manager

In Adapter.Stop(), call a.clusterMgr.Stop() before unmounting (if non-nil).

Add Enabled bool field to ClusterConfig in internal/config/config.go so cluster mode is explicitly opt-in.

Acceptance criteria

  • All existing single-node tests pass unchanged
  • FileSystem.coordinator is nil when cluster is disabled; no code branch is taken
  • New test: create Adapter with config.Cluster.Enabled = true, call Start, verify ClusterManager starts and is stopped on Stop
  • go test -race ./internal/adapter/... ./internal/fuse/... passes

Sequencing

Depends on A1-1 (ConsensusLog interface) and A1-2 (DistributedCoordinator interface). Must land before A2-2, A2-3, A2-4.

Activity

  1. added
    type: enhancement
    priority: critical
    area: fuse
    on Apr 7, 2026
  2. scttfrdmn commented on Jul 30, 2026

    @scttfrdmn
    OwnerAuthor

    Note from the v0.10.0 review — this cannot compile as written

    Flagging a blocker found while auditing the distributed package, so the work is not attempted
    against a false premise.

    config.ClusterConfig and distributed.ClusterConfig are disjoint types. The former
    (internal/config/config.go) has 7 fields plus Redis; the latter
    (internal/distributed/cluster.go) has 18, with different names. So the natural implementation:

    distributed.NewClusterManager(&a.config.Cluster)

    is a type error. A translation layer between the two is needed, and no currently-filed issue
    covers it. That should either be added to this issue's scope or split out as a prerequisite.

    distributed.ClusterConfig has no Enabled field, even though internal/distributed/doc.go
    shows example code setting it in two places. Those examples do not compile. The gating flag
    exists only on config.ClusterConfig, so the enable/disable decision has to happen in the
    adapter before constructing the distributed config.

    Also relevant to sequencing: Adapter (internal/adapter/adapter.go) and FileSystem
    (internal/fuse/filesystem.go) both currently have no cluster or coordinator field at all, and
    ClusterManager.GetCoordinator has no non-test caller. Wiring is genuinely from scratch rather
    than connecting two existing halves.

    See #169 for a broader evaluation of whether the consensus direction is the right one before
    this lands.

  3. scttfrdmn commented on Aug 2, 2026

    @scttfrdmn
    OwnerAuthor

    Correction: two of this issue's steps are type errors as written

    Re-verified against main during the v0.10.1 audit. The intent is right; three specifics are not.

    1. config.ClusterConfig and distributed.ClusterConfig are disjoint types. The issue says to call distributed.NewClusterManager(&a.config.Cluster). That does not compile:

    config.ClusterConfig (internal/config/config.go:401) distributed.ClusterConfig (internal/distributed/cluster.go:36)
    shared fields NodeID, ListenAddr, AdvertiseAddr, SeedNodes, ReplicationFactor, ConsistencyLevel same six
    only here Enabled, Redis RedisConfig JoinTimeout, ElectionTimeout, HeartbeatInterval, LeadershipTTL, GossipInterval, GossipFanout, MaxGossipPacket, CacheReplication, MaxConcurrentOps, OperationTimeout, RetryAttempts, RetryBackoff

    Six of eight fields overlap by name, which is what makes the mistake easy. The work item is therefore a translation function — func clusterConfigFrom(c config.ClusterConfig) *distributed.ClusterConfig — not a pointer cast. It has to decide what to do with the twelve distributed-only fields (NewClusterManager defaults them, so passing zero values is acceptable but should be explicit) and with Redis, which the distributed type cannot carry at all.

    2. Enabled already exists on config.ClusterConfig (config.go:402). The step "Add Enabled bool field to ClusterConfig in internal/config/config.go" is already done. It is distributed.ClusterConfig that lacks it — and that is arguably correct, since whether to construct a manager is the caller's decision, not the manager's.

    3. NewClusterManager returns two values, (*ClusterManager, error) (cluster.go:182). The issue's step 1 shows a single-value call.

    Related, and worth fixing in the same change: internal/distributed/doc.go has two examples that do not compile against the type they claim to configure — :79 and :316 set Enabled: true, :324 sets FailureTimeout, and distributed.ClusterConfig has neither field. The struct listing at :232-245 is a third, independent shape: it lists Enabled and FailureTimeout and omits the twelve real fields. Whoever wires this up will read those examples first.

    What is accurate and unchanged: internal/adapter/adapter.go never instantiates ClusterManager; FileSystem has no coordinator field; SetBackend (cluster.go:621), SetCache (:633), and GetCoordinator (:664) all exist with the signatures the issue assumes. The nil-coordinator-is-zero-overhead design is sound.

    One addition to the acceptance criteria: assert the translated values, not that translation happened. A test that constructs the manager and checks it is non-nil would pass on a function that ignored its argument. v0.10.1 shipped fixes for eighteen config fields that were settable and read by nothing, all of which had that shape.

  4. added
    effort: large
    on Aug 3, 2026
  5. added a commit that references this issue on Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: fuseeffort: largepriority: criticaltype: enhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions