|
| None | add_source_subcommands (argparse._SubParsersAction roadmap_commands) |
| Path | _source_dir (argparse.Namespace args) |
| "tuple[Path | None, int | None]" | _resolve_root_or_exit (argparse.Namespace args) |
| None | _emit_envelope (SourceError error, bool as_json) |
| None | _print_error_envelope (dict envelope, bool as_json) |
| "str | None" | _git_status_porcelain (Path root) |
| int | _cmd_source_format (argparse.Namespace args) |
| int | _cmd_source_validate (argparse.Namespace args) |
| int | _cmd_source_lint (argparse.Namespace args) |
| list[dict] | _lint_inactive_tracks (dict categorized) |
| int | _cmd_source_diff (argparse.Namespace args) |
| dict | _diff_units (Path root) |
| "tuple[tuple, dict]" | _logical_key (str kind, scanned, model) |
| dict | _unit (str kind, dict keyobj, str path, model) |
| dict | _compare_units (dict units_a, dict units_b) |
| dict | _locate (dict unit) |
| tuple | _diff_sort_key (dict record) |
| None | _print_diff_human (dict result) |
| | _migration_registry_factory () |
| "tuple[Path, Path]" | _resolve_migrate_paths (argparse.Namespace args) |
| int | _cmd_source_migrate (argparse.Namespace args) |
| None | _print_migrate_success (dict payload, bool as_json, bool quiet) |
| int | _cmd_hash_preimage (argparse.Namespace args) |
CLI commands for the registry AuthoredSource format (Plan 142 P1.3 + 142j R5).
Purpose
-------
Expose the §10 read-only ``source`` surface: ``format [--check]`` (the §3.2
idempotent canonicaliser, with the 142j write-mode clean-tree precondition),
``validate`` (the §5.3 steps 1–6 chain, fail-fast), ``lint`` (non-failing style
warnings), ``diff`` (a semantic diff over parsed/canonical models), and
``hash-preimage`` (the §3.2 debug preimage). The destructive ``migrate`` command
is Plan 142m.
Responsibilities
----------------
- Resolve the source tree (default ``<workspace>/oc_chat/roadmap/source``).
- Run each read-only command, emitting the §8 ``build_envelope`` on failure and
each command's own success payload otherwise.
- Enforce the write-mode clean-tree precondition + the worker discovery guard.
Diagnostics
-----------
Domain: OC_CHAT.MAIN
Levels:
L2 - CLI lifecycle
L3 - command argument summaries
L4 - subcommand dispatch details
Contracts
---------
- Read-only except ``source format`` (without ``--check``) which rewrites
non-canonical records in place (refused on a dirty resolved-source tree).
- Non-zero exit emits the §10 envelope; ``diff`` owns 0/1/2 (exit 1 = "differs").
Dependencies
------------
- argparse (CLI parsing)
- oc_chat.registry.discovery (workspace/registry resolution + the worker guard)
- oc_diagnostics (_dbg structured logger)
- oc_chat.registry.backends.sqlite (SQLiteBackend connection for the logical-state hash preimage)
- oc_chat.registry.regenerate.cross_record (validate_cross_record, the cross-record step of validate)
- oc_chat.registry.regenerate.envelope (RegenerateError, SRC_TREE_DIRTY, build_envelope and exit_code_for)
- oc_chat.registry.regenerate.lock (acquire and release the shared regenerate lock around migrate)
- oc_chat.registry.regenerate.pipeline (_categorize, the record load and schema steps of validate and lint)
- oc_chat.registry.source.canonical (format_source_tree canonicaliser and load_record for diff and hash-preimage)
- oc_chat.registry.source.errors (SourceError and SourceScanError for the error envelopes and exit codes)
- oc_chat.registry.source.hashing (raw-source-tree and source hashes plus the hash-preimage projections)
- oc_chat.registry.source.scanner (scan_source_tree over the resolved source tree)
- oc_chat.registry.source_migrations.errors (MigrateError for the target schema version refusal)
- oc_chat.registry.source_migrations.runner (production migration provider, run_migration and target semver validation)
- yaml (YAML output for hash-preimage)
- git (not imported; run as a subprocess for rev-parse and status --porcelain, the clean-tree precondition of write-mode source format)
| int oc_chat.registry.cli.source._cmd_source_migrate |
( |
argparse.Namespace | args | ) |
|
|
protected |
The ``roadmap source migrate`` handler — pipeline steps 0-2 (semver shape,
root resolution, the shared lock) + the runner (steps 3-13). Mirrors
``regenerate/pipeline`` lock choreography: step 0 in its OWN pre-lock
try/except; a separate try wrapping the runner whose
``except (SourceError, RegenerateError)`` catches BOTH the migrate refusals and
the lock's ``REGEN_LOCK_HELD``, with a ``finally`` that releases the lock
UNCONDITIONALLY.
Definition at line 515 of file source.py.