Back to Qwen Code

Derived Config ownership

docs/design/derived-config-ownership.md

0.22.23.7 KB
Original Source

Derived Config ownership

Config derivation is a state-ownership operation, not a clone. deriveConfig keeps the existing prototype overlay model behind one boundary while production callers are migrated incrementally.

StateOwnershipContract
workspace path and contextshared until explicitly overlaidWorktree profiles must override the paired public getters and private reads together.
file service and discoveryshared until explicitly overlaidWorktree profiles rebind both to the target workspace.
tool registryshared or explicitly replacedAgent profiles that rebuild it own cleanup of the replacement registry.
permission managershared or explicitly replacedAgent profiles preserve the existing strip/restore lifecycle.
approval modesharedDerived profiles may read the inherited mode but cannot mutate it until they own an independent permission-manager lifecycle.
file-read cachechild-localThe first getter call installs a fresh cache on the derived Config.
memory-pressure monitorchild-localThe first getter call installs a new monitor using the inherited configuration snapshot.
active todo statechild-localThe first mutation installs independent maps.
chat recording serviceshared unless hiddenScoped profiles may hide it through a getter override.
goal runtimeprohibitedA derived Config cannot resolve the parent conversation's runtime.
session writer stateprohibitedWriter ownership stays with the canonical session Config.
canonical lifecycleprohibitedA derived Config cannot initialize, start a session, relocate the workspace, or clean up inherited Team/Arena runtime resources.
approval mode mutationprohibitedA derived Config cannot restore or strip rules on the canonical PermissionManager.

Migration order:

  1. Worktree contexts.
  2. Agent execution contexts.
  3. Scoped memory/remember/skill-review profiles.
  4. Enforce that production prototype derivation occurs only inside deriveConfig.

The factory intentionally accepts public getter overrides only. Private field rebinding needed by worktree contexts remains a separate migration concern and must be encoded without exposing arbitrary Config mutation.

Approval-mode override wrappers that call Config prototype mutators remain outside deriveConfig until their strip/restore lifecycle is owned independently from the parent permission manager.