oc_chat
Loading...
Searching...
No Matches
oc_chat.scripts.migration_preflight Namespace Reference

Classes

class  Stamp
class  BranchRow
class  WorktreeRow

Functions

Stamp _iso_now ()
Stamp _stamp_from_arg (str|None value)
tuple[int, str, str] _run_cmd (Sequence[str] args, Path cwd, int timeout=DEFAULT_TIMEOUT_SECONDS)
Path write_branch_inventory (Path repo_root, Path out_dir, Stamp stamp, *, int timeout=DEFAULT_TIMEOUT_SECONDS)
Path write_health_baseline (Path repo_root, Path out_dir, Stamp stamp, *, int timeout=DEFAULT_TIMEOUT_SECONDS)
Path write_test_baseline (Path repo_root, Path out_dir, Stamp stamp, *, int timeout=DEFAULT_TIMEOUT_SECONDS)
Path write_filter_repo_dryrun (Path repo_root, Path out_dir, Stamp stamp, *, int timeout=DEFAULT_TIMEOUT_SECONDS)
list[Path] run_all (Path repo_root, Path out_dir, Stamp stamp, *, int timeout=DEFAULT_TIMEOUT_SECONDS)
Path write_summary (Path out_dir, Stamp stamp, Sequence[Path] artifacts)
list[BranchRow] _collect_branches (Path repo_root, int timeout)
list[WorktreeRow] _collect_worktrees (Path repo_root, int timeout)
set[str] _merged_branches (Path repo_root, int timeout)
str _ahead_behind (Path repo_root, str branch, int timeout)
tuple[str, str, str] _worktree_commit_info (Path repo_root, str worktree, int timeout)
list[dict[str, str]] _parse_worktree_records (str text)
int|None _parse_test_count (str text)
str|None _filter_repo_mode (Path repo_root, int timeout)
list[str] _filter_repo_command (str mode)
bool _safe_clone_dir (Path clone_dir, Path repo_root)
None _write_filter_report (Path path, Stamp stamp, str status, str reason, *, str|None command=None, int|None returncode=None, str stdout="", str stderr="")
tuple[str, str, str, str] _split_tab4 (str line)
str _tail (str text, int lines=25)
str _md (str value)
Path _resolve_repo_root (str|None raw)
Path _resolve_out_dir (Path repo_root, str|None raw)
None _add_common (argparse.ArgumentParser parser)
list[Path] _dispatch (argparse.Namespace args)
argparse.ArgumentParser build_parser ()
int main (list[str]|None argv=None)

Variables

str DEFAULT_OUT_DIR = ".migration"
int DEFAULT_TIMEOUT_SECONDS = 300
 COUNT_RE = re.compile(r"(\d+)\s+(?:tests?|items?)\s+collected", re.IGNORECASE)
 PER_FILE_COUNT_RE = re.compile(r"^[^:\n]+:\s*(\d+)\s*$", re.MULTILINE)

Detailed Description

M3.1 monorepo migration pre-flight artifact generator.

Purpose
-------
Capture the non-destructive baselines needed before the future M3.2
``git filter-repo`` migration into the Option_C monorepo.

Responsibilities
----------------
- Write branch/worktree inventory artifacts.
- Capture ``oct health --json`` output or a structured skip stub.
- Record the pytest collection count used for later parity checks.
- Run a filter-repo rehearsal only inside a throwaway temp clone.
- Write a summary artifact that separates automated and manual steps.

Diagnostics
-----------
Domain: OC_CHAT.MAIN
Levels:
    L2 - CLI lifecycle and artifact writes
    L3 - subprocess and tool-availability decisions
    L4 - row-level inventory details

Contracts
---------
- No live branch or repository history is rewritten.
- Missing optional tools write SKIPPED artifacts and return success.
- Subprocesses run with argument lists and never through ``shell=True``.
- The filter-repo command is never run against the source repository root.

Dependencies
------------
- git (not imported; CLI run as a subprocess for the branch and worktree inventory, the temp clone and the optional git filter-repo rehearsal)
- pytest (not imported; run as python -m pytest --collect-only for the collection-count baseline)
- oct (not imported; optional CLI run as oct health --json for the health baseline)
- oc_diagnostics (structured debug logging via _dbg)

Function Documentation

◆ _add_common()

None oc_chat.scripts.migration_preflight._add_common ( argparse.ArgumentParser parser)
protected

Definition at line 656 of file migration_preflight.py.

Here is the caller graph for this function:

◆ _ahead_behind()

str oc_chat.scripts.migration_preflight._ahead_behind ( Path repo_root,
str branch,
int timeout )
protected

Definition at line 519 of file migration_preflight.py.

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

◆ _collect_branches()

list[BranchRow] oc_chat.scripts.migration_preflight._collect_branches ( Path repo_root,
int timeout )
protected

Definition at line 429 of file migration_preflight.py.

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

◆ _collect_worktrees()

list[WorktreeRow] oc_chat.scripts.migration_preflight._collect_worktrees ( Path repo_root,
int timeout )
protected

Definition at line 471 of file migration_preflight.py.

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

◆ _dispatch()

list[Path] oc_chat.scripts.migration_preflight._dispatch ( argparse.Namespace args)
protected

Definition at line 663 of file migration_preflight.py.

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

◆ _filter_repo_command()

list[str] oc_chat.scripts.migration_preflight._filter_repo_command ( str mode)
protected

Definition at line 590 of file migration_preflight.py.

Here is the caller graph for this function:

◆ _filter_repo_mode()

str | None oc_chat.scripts.migration_preflight._filter_repo_mode ( Path repo_root,
int timeout )
protected

Definition at line 578 of file migration_preflight.py.

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

◆ _iso_now()

Stamp oc_chat.scripts.migration_preflight._iso_now ( )
protected

Definition at line 102 of file migration_preflight.py.

Here is the caller graph for this function:

◆ _md()

str oc_chat.scripts.migration_preflight._md ( str value)
protected

Definition at line 643 of file migration_preflight.py.

Here is the caller graph for this function:

◆ _merged_branches()

set[str] oc_chat.scripts.migration_preflight._merged_branches ( Path repo_root,
int timeout )
protected

Definition at line 508 of file migration_preflight.py.

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

◆ _parse_test_count()

int | None oc_chat.scripts.migration_preflight._parse_test_count ( str text)
protected

Definition at line 568 of file migration_preflight.py.

Here is the caller graph for this function:

◆ _parse_worktree_records()

list[dict[str, str]] oc_chat.scripts.migration_preflight._parse_worktree_records ( str text)
protected

Definition at line 552 of file migration_preflight.py.

Here is the caller graph for this function:

◆ _resolve_out_dir()

Path oc_chat.scripts.migration_preflight._resolve_out_dir ( Path repo_root,
str | None raw )
protected

Definition at line 651 of file migration_preflight.py.

Here is the caller graph for this function:

◆ _resolve_repo_root()

Path oc_chat.scripts.migration_preflight._resolve_repo_root ( str | None raw)
protected

Definition at line 647 of file migration_preflight.py.

Here is the caller graph for this function:

◆ _run_cmd()

tuple[int, str, str] oc_chat.scripts.migration_preflight._run_cmd ( Sequence[str] args,
Path cwd,
int timeout = DEFAULT_TIMEOUT_SECONDS )
protected
Run a subprocess command with captured output.

Definition at line 118 of file migration_preflight.py.

Here is the caller graph for this function:

◆ _safe_clone_dir()

bool oc_chat.scripts.migration_preflight._safe_clone_dir ( Path clone_dir,
Path repo_root )
protected

Definition at line 596 of file migration_preflight.py.

Here is the caller graph for this function:

◆ _split_tab4()

tuple[str, str, str, str] oc_chat.scripts.migration_preflight._split_tab4 ( str line)
protected

Definition at line 632 of file migration_preflight.py.

Here is the caller graph for this function:

◆ _stamp_from_arg()

Stamp oc_chat.scripts.migration_preflight._stamp_from_arg ( str | None value)
protected

Definition at line 110 of file migration_preflight.py.

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

◆ _tail()

str oc_chat.scripts.migration_preflight._tail ( str text,
int lines = 25 )
protected

Definition at line 639 of file migration_preflight.py.

Here is the caller graph for this function:

◆ _worktree_commit_info()

tuple[str, str, str] oc_chat.scripts.migration_preflight._worktree_commit_info ( Path repo_root,
str worktree,
int timeout )
protected

Definition at line 534 of file migration_preflight.py.

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

◆ _write_filter_report()

None oc_chat.scripts.migration_preflight._write_filter_report ( Path path,
Stamp stamp,
str status,
str reason,
* ,
str | None command = None,
int | None returncode = None,
str stdout = "",
str stderr = "" )
protected

Definition at line 605 of file migration_preflight.py.

Here is the caller graph for this function:

◆ build_parser()

argparse.ArgumentParser oc_chat.scripts.migration_preflight.build_parser ( )

Definition at line 680 of file migration_preflight.py.

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

◆ main()

int oc_chat.scripts.migration_preflight.main ( list[str] | None argv = None)

Definition at line 698 of file migration_preflight.py.

Here is the call graph for this function:

◆ run_all()

list[Path] oc_chat.scripts.migration_preflight.run_all ( Path repo_root,
Path out_dir,
Stamp stamp,
* ,
int timeout = DEFAULT_TIMEOUT_SECONDS )
Run all pre-flight producers and write the summary.

Definition at line 372 of file migration_preflight.py.

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

◆ write_branch_inventory()

Path oc_chat.scripts.migration_preflight.write_branch_inventory ( Path repo_root,
Path out_dir,
Stamp stamp,
* ,
int timeout = DEFAULT_TIMEOUT_SECONDS )
Write branch/worktree inventory markdown.

Definition at line 146 of file migration_preflight.py.

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

◆ write_filter_repo_dryrun()

Path oc_chat.scripts.migration_preflight.write_filter_repo_dryrun ( Path repo_root,
Path out_dir,
Stamp stamp,
* ,
int timeout = DEFAULT_TIMEOUT_SECONDS )
Run filter-repo only inside a throwaway clone and write the report.

Definition at line 287 of file migration_preflight.py.

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

◆ write_health_baseline()

Path oc_chat.scripts.migration_preflight.write_health_baseline ( Path repo_root,
Path out_dir,
Stamp stamp,
* ,
int timeout = DEFAULT_TIMEOUT_SECONDS )
Write ``oct health --json`` output or a structured SKIPPED stub.

Definition at line 218 of file migration_preflight.py.

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

◆ write_summary()

Path oc_chat.scripts.migration_preflight.write_summary ( Path out_dir,
Stamp stamp,
Sequence[Path] artifacts )
Write the pre-flight summary markdown.

Definition at line 393 of file migration_preflight.py.

Here is the caller graph for this function:

◆ write_test_baseline()

Path oc_chat.scripts.migration_preflight.write_test_baseline ( Path repo_root,
Path out_dir,
Stamp stamp,
* ,
int timeout = DEFAULT_TIMEOUT_SECONDS )
Write pytest collection-count baseline.

Definition at line 252 of file migration_preflight.py.

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

Variable Documentation

◆ COUNT_RE

oc_chat.scripts.migration_preflight.COUNT_RE = re.compile(r"(\d+)\s+(?:tests?|items?)\s+collected", re.IGNORECASE)

Definition at line 65 of file migration_preflight.py.

◆ DEFAULT_OUT_DIR

str oc_chat.scripts.migration_preflight.DEFAULT_OUT_DIR = ".migration"

Definition at line 63 of file migration_preflight.py.

◆ DEFAULT_TIMEOUT_SECONDS

int oc_chat.scripts.migration_preflight.DEFAULT_TIMEOUT_SECONDS = 300

Definition at line 64 of file migration_preflight.py.

◆ PER_FILE_COUNT_RE

oc_chat.scripts.migration_preflight.PER_FILE_COUNT_RE = re.compile(r"^[^:\n]+:\s*(\d+)\s*$", re.MULTILINE)

Definition at line 66 of file migration_preflight.py.