"""okstra-ctl 와 okstra-central 가 공유하는 순수 헬퍼 패키지.

기존 단일 모듈 `okstra_ctl_lib` 를 도메인 단위 서브모듈로 분해한 결과이며,
모든 public 심볼을 패키지 루트에서 재노출한다. 호출자는
`from okstra_ctl import X` 형태로 직접 import 한다.
"""
from __future__ import annotations

# Public API — keep import order topological (leaves first) to avoid surprises.
from .ids import (
    build_container_session_name,
    build_run_id,
    parse_run_id,
    run_id_to_session_name,
    slugify_task_segment,
    _escape_segment_for_join,
    _safe_fs_segment,
)
from .locks import central_lock, task_lock_filename
from .invocation import invocation_path, save_invocation, load_invocation
from .jsonl import (
    append_jsonl,
    read_jsonl,
    remove_jsonl_row,
    rotate_recent_if_needed,
)
from .project_meta import (
    _project_meta_path,
    load_project_meta,
    upsert_project_meta,
)
from .qa_commands import (
    ALLOWED_CATEGORIES,
    QaCommandsError,
    find_denied_tokens,
    format_errors,
    validate_qa_cmd,
    validate_qa_commands,
)
from .index import (
    _replace_or_append_row,
    record_start,
    reserve_run_in_active,
    remove_reservation,
)
from .reconcile import (
    DEFAULT_ABORT_AFTER_SECONDS,
    _now_iso,
    _parse_iso,
    _read_run_manifest_validation,
    _reconcile_active_locked,
    normalize_central_status,
    normalize_reconciled_report_status,
    reconcile_active,
    reconcile_recent,
)
from .listing import (
    _parse_since,
    absolute_final_report_path,
    find_row_by_run_id,
    format_projects_table,
    format_runs_table,
    format_show,
    list_projects,
    list_runs,
)
from .resolver import ResolveError, _all_run_ids, resolve_last, resolve_run_id
from .run_index_row import read_run_index
from .sequence import predict_next_run_seq
from .tmux import _shell_quote, build_tmux_command
from .batch import expand_selectors, make_batch_id, write_batch_meta
from .backfill import (
    _apply_backfill_meta,
    backfill_project,
    discover_project_roots,
    mark_backfilled,
)
from .paths import compute_run_paths, next_run_seq, resolve_under_root
from .run_context import (
    compute_and_write_run_context,
    read_run_context,
    read_run_inputs,
    task_mutex,
    write_run_inputs,
)

__all__ = [
    "DEFAULT_ABORT_AFTER_SECONDS",
    "ResolveError",
    "absolute_final_report_path",
    "append_jsonl",
    "backfill_project",
    "build_container_session_name",
    "build_run_id",
    "build_tmux_command",
    "central_lock",
    "compute_and_write_run_context",
    "compute_run_paths",
    "discover_project_roots",
    "expand_selectors",
    "find_row_by_run_id",
    "format_projects_table",
    "format_runs_table",
    "format_show",
    "invocation_path",
    "list_projects",
    "list_runs",
    "load_invocation",
    "load_project_meta",
    "make_batch_id",
    "mark_backfilled",
    "next_run_seq",
    "normalize_central_status",
    "normalize_reconciled_report_status",
    "parse_run_id",
    "predict_next_run_seq",
    "read_jsonl",
    "read_run_index",
    "read_run_context",
    "read_run_inputs",
    "reconcile_active",
    "reconcile_recent",
    "record_start",
    "remove_jsonl_row",
    "remove_reservation",
    "reserve_run_in_active",
    "resolve_last",
    "resolve_run_id",
    "resolve_under_root",
    "rotate_recent_if_needed",
    "run_id_to_session_name",
    "save_invocation",
    "slugify_task_segment",
    "task_lock_filename",
    "task_mutex",
    "upsert_project_meta",
    "write_batch_meta",
    "write_run_inputs",
]
