oc_chat
Loading...
Searching...
No Matches
oc_chat.registry.discovery Namespace Reference

Classes

class  WorkerRegistryError
class  RegistryLocation

Functions

Path discover_registry_path (str|os.PathLike[str]|None start=None, Mapping[str, str]|None env=None)
RegistryLocation discover_registry_location (str|os.PathLike[str]|None start=None, Mapping[str, str]|None env=None, str|os.PathLike[str]|None registry_path=None, str|os.PathLike[str]|None workspace_root=None)
None _worker_registry_guard (Mapping[str, str] env, Path workspace_root)
Path _discover_path (Path anchor, Mapping[str, str] env, Path workspace_root)
Path _resolve_workspace_root (Path anchor, str|os.PathLike[str]|None workspace_root)
Path _workspace_root_from_manifest (Path manifest)
Path|None _find_workspace_manifest (Path anchor)
Path|None _git_common_dir (Path anchor)
Path _anchor_path (str|os.PathLike[str]|None start)
Path _absolute_path (Path path, Path base)

Variables

str REGISTRY_ENV_VAR = "OC_AGENT_REGISTRY"
str WORKER_ENV_VAR = "OC_AGENT_WORKER"
str WORKSPACE_MANIFEST = ".option_c_workspace.json"
str DEFAULT_REGISTRY_RELATIVE = Path(".option_c") / "orchestration" / "registry.sqlite"
str DEFAULT_ORCHESTRATION_RELATIVE = Path(".option_c") / "orchestration"
str DEFAULT_CHECKPOINT_NAME = "state.json"

Detailed Description

Registry location discovery.

Purpose
-------
Resolve the SQLite registry location in the order specified by the
orchestration registry design-lock document.

Responsibilities
----------------
- Honor ``OC_AGENT_REGISTRY`` when it points at an absolute path.
- Detect ``.option_c_workspace.json`` and derive the shared registry path.
- Fall back through git common-dir and project-root locations.
- Return workspace metadata needed by the init seed path.

Diagnostics
-----------
Domain: OC_CHAT.MAIN
Levels:
    L2 - lifecycle events
    L3 - semantic details
    L4 - deep tracing

Contracts
---------
- Discovery is read-only and does not create directories or files.
- Environment override paths must be absolute.

Dependencies
------------
- oc_diagnostics (structured debug logging via _dbg)
- oc_chat.core._paths (workspace root fallback)

Function Documentation

◆ _absolute_path()

Path oc_chat.registry.discovery._absolute_path ( Path path,
Path base )
protected

Definition at line 240 of file discovery.py.

Here is the caller graph for this function:

◆ _anchor_path()

Path oc_chat.registry.discovery._anchor_path ( str | os.PathLike[str] | None start)
protected

Definition at line 236 of file discovery.py.

Here is the caller graph for this function:

◆ _discover_path()

Path oc_chat.registry.discovery._discover_path ( Path anchor,
Mapping[str, str] env,
Path workspace_root )
protected

Definition at line 157 of file discovery.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _find_workspace_manifest()

Path | None oc_chat.registry.discovery._find_workspace_manifest ( Path anchor)
protected

Definition at line 208 of file discovery.py.

Here is the caller graph for this function:

◆ _git_common_dir()

Path | None oc_chat.registry.discovery._git_common_dir ( Path anchor)
protected

Definition at line 217 of file discovery.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _resolve_workspace_root()

Path oc_chat.registry.discovery._resolve_workspace_root ( Path anchor,
str | os.PathLike[str] | None workspace_root )
protected

Definition at line 181 of file discovery.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _worker_registry_guard()

None oc_chat.registry.discovery._worker_registry_guard ( Mapping[str, str] env,
Path workspace_root )
protected
Plan 142j R7: in worker context (``OC_AGENT_WORKER=1``), ``OC_AGENT_REGISTRY``
MUST be set, absolute, and resolve INSIDE this worktree's
``.option_c/orchestration/`` boundary; else fail closed (``WorkerRegistryError``).

A not-yet-created ``registry.sqlite`` **inside** the boundary is VALID (the
per-worktree store is created on first use — location, not existence, is
checked). Unset/empty OR resolving OUTSIDE the boundary (main repo / sibling
worktree / arbitrary temp) is fail-closed. Non-worker local CLI is unaffected
(the existing workspace/git fallback still applies).

Definition at line 122 of file discovery.py.

Here is the caller graph for this function:

◆ _workspace_root_from_manifest()

Path oc_chat.registry.discovery._workspace_root_from_manifest ( Path manifest)
protected

Definition at line 196 of file discovery.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ discover_registry_location()

RegistryLocation oc_chat.registry.discovery.discover_registry_location ( str | os.PathLike[str] | None start = None,
Mapping[str, str] | None env = None,
str | os.PathLike[str] | None registry_path = None,
str | os.PathLike[str] | None workspace_root = None )
Resolve registry path and metadata needed by ``init``.

Definition at line 94 of file discovery.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ discover_registry_path()

Path oc_chat.registry.discovery.discover_registry_path ( str | os.PathLike[str] | None start = None,
Mapping[str, str] | None env = None )
Resolve the registry SQLite path using spec section 6.1 order.

Definition at line 85 of file discovery.py.

Here is the call graph for this function:

Variable Documentation

◆ DEFAULT_CHECKPOINT_NAME

str oc_chat.registry.discovery.DEFAULT_CHECKPOINT_NAME = "state.json"

Definition at line 59 of file discovery.py.

◆ DEFAULT_ORCHESTRATION_RELATIVE

str oc_chat.registry.discovery.DEFAULT_ORCHESTRATION_RELATIVE = Path(".option_c") / "orchestration"

Definition at line 58 of file discovery.py.

◆ DEFAULT_REGISTRY_RELATIVE

str oc_chat.registry.discovery.DEFAULT_REGISTRY_RELATIVE = Path(".option_c") / "orchestration" / "registry.sqlite"

Definition at line 57 of file discovery.py.

◆ REGISTRY_ENV_VAR

str oc_chat.registry.discovery.REGISTRY_ENV_VAR = "OC_AGENT_REGISTRY"

Definition at line 54 of file discovery.py.

◆ WORKER_ENV_VAR

str oc_chat.registry.discovery.WORKER_ENV_VAR = "OC_AGENT_WORKER"

Definition at line 55 of file discovery.py.

◆ WORKSPACE_MANIFEST

str oc_chat.registry.discovery.WORKSPACE_MANIFEST = ".option_c_workspace.json"

Definition at line 56 of file discovery.py.