oc_chat
Loading...
Searching...
No Matches
oc_chat.registry.regenerate.pipeline Namespace Reference

Classes

class  RegenerateResult

Functions

tuple[PromotedItem, str] _load_promoted (Any scanned)
dict[str, list] _categorize (list records)
None _init_temp_db (Path temp_path)
None _clear_roadmap_tables (sqlite3.Connection conn)
None _assert_source_foreign_keys (sqlite3.Connection conn)
str _build_and_publish (dict[str, list] categorized, Path db_path, str computed_source_hash, Path source_dir, str expected_raw_hash)
None _best_effort_unlink (str path)
RegenerateResult regenerate (Path source_dir, Path db_path, *, str backend="sqlite", str scope="authored", Optional[Path] lock_path=None, bool force=False)
str _stage_for (BaseException error)

Variables

 _RUNTIME_TABLES = frozenset({"agents", "rounds", "plans", "operation_log"})
tuple _ROADMAP_TABLES

Detailed Description

The 7-step ``regenerate`` orchestration (Plan 142 P1.4, §5.3).

Purpose
-------
Drive scan -> parse/load -> local schema -> canonicalisation-check ->
``source_hash`` -> cross-record -> temp-DB build + derive-verify +
verification-stamp publish-gate + WAL-safe atomic swap, returning a result that
carries the §10 envelope. A later step never begins until the earlier one
passes; a failure carries the §10 hash-field nullability for its stage.

Responsibilities
----------------
- ``regenerate(source_dir, db_path, ...)`` — run the pipeline, build the
  worktree-local store, never touching the shared main-repo registry.

Diagnostics
-----------
Domain: OC_CHAT.MAIN
Levels:
    L2 - pipeline lifecycle
    L3 - per-step progress
    L4 - swap/verify details

Contracts
---------
- Idempotent: identical inputs -> identical source/logical hashes (no
  hash-contributing row changes on a no-op).
- Verify-before-USE: the built DB is never swapped/hashed/read until the
  derive-verify passes; the stamp is written before the atomic swap.

Dependencies
------------
- oc_diagnostics (structured debug logging via _dbg)
- oc_chat.registry.backends.sqlite (SQLiteBackend and RegistrySeed to initialise the temp DB)
- oc_chat.registry.regenerate.build (build_roadmap inserts the roadmap rows into the temp DB)
- oc_chat.registry.regenerate.cross_record (validate_cross_record, the step-6 cross-record checks)
- oc_chat.registry.regenerate.derive_verify (version dedup, derivation and the step-7 derive-verify gate)
- oc_chat.registry.regenerate.envelope (RegenerateError, the REGEN_* and SRC_STRICT_TYPE codes and build_envelope)
- oc_chat.registry.regenerate.lock (acquire and release the regenerate lock around the run)
- oc_chat.registry.regenerate.verified_projection (write and assert the verification stamp before the swap)
- oc_chat.registry.source.canonical (record loading, frontmatter split, YAML feature guard and the canonicalisation check)
- oc_chat.registry.source.errors (SourceError caught for the failure envelope, SourceValidationError raised on a promoted item's strict-type failure and SourceScanError to tell the scan stage apart)
- oc_chat.registry.source.hashing (raw-source-tree, source and logical-state hashes)
- oc_chat.registry.source.promoted_item (PromotedItem model for promoted item records)
- oc_chat.registry.source.scanner (scan_source_tree, step 1 of the pipeline)
- oc_chat.registry.store_scope (stamp_authored_projection so live commands refuse the built store)
- pydantic (ValidationError from PromotedItem validation)
- yaml (safe_load of promoted item frontmatter)

Function Documentation

◆ _assert_source_foreign_keys()

None oc_chat.registry.regenerate.pipeline._assert_source_foreign_keys ( sqlite3.Connection conn)
protected
Run foreign_key_check, tolerating Option A runtime-table references.

Definition at line 217 of file pipeline.py.

Here is the caller graph for this function:

◆ _best_effort_unlink()

None oc_chat.registry.regenerate.pipeline._best_effort_unlink ( str path)
protected
Unlink ``path`` tolerating Windows transient locks (§5.3, post-checkpoint).

Definition at line 308 of file pipeline.py.

Here is the caller graph for this function:

◆ _build_and_publish()

str oc_chat.registry.regenerate.pipeline._build_and_publish ( dict[str, list] categorized,
Path db_path,
str computed_source_hash,
Path source_dir,
str expected_raw_hash )
protected
Step 7: build temp DB -> derive-verify -> stamp -> hash -> WAL-safe swap.

Definition at line 231 of file pipeline.py.

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

◆ _categorize()

dict[str, list] oc_chat.registry.regenerate.pipeline._categorize ( list records)
protected

Definition at line 162 of file pipeline.py.

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

◆ _clear_roadmap_tables()

None oc_chat.registry.regenerate.pipeline._clear_roadmap_tables ( sqlite3.Connection conn)
protected

Definition at line 212 of file pipeline.py.

Here is the caller graph for this function:

◆ _init_temp_db()

None oc_chat.registry.regenerate.pipeline._init_temp_db ( Path temp_path)
protected

Definition at line 194 of file pipeline.py.

Here is the caller graph for this function:

◆ _load_promoted()

tuple[PromotedItem, str] oc_chat.registry.regenerate.pipeline._load_promoted ( Any scanned)
protected

Definition at line 137 of file pipeline.py.

Here is the caller graph for this function:

◆ _stage_for()

str oc_chat.registry.regenerate.pipeline._stage_for ( BaseException error)
protected

Definition at line 397 of file pipeline.py.

Here is the caller graph for this function:

◆ regenerate()

RegenerateResult oc_chat.registry.regenerate.pipeline.regenerate ( Path source_dir,
Path db_path,
* ,
str backend = "sqlite",
str scope = "authored",
Optional[Path] lock_path = None,
bool force = False )
Run the 7-step pipeline; build the worktree-local store at ``db_path``.

``lock_path`` (R5): the regenerate lock file. The CLI (and any caller wanting
same-worktree mutual exclusion) MUST pass the explicit workspace lock path
(``<workspace>/.option_c/orchestration/regenerate.lock``, independent of
``--db``). ``lock_path=None`` is a **test/library compatibility default only**
— resolved by the side-effect-free rule ``db_path.parent / "regenerate.lock"``
(never source_dir-derived, never workspace discovery); it must never silently
become the production contract (Codex-R04-P1). ``force`` reclaims a stale lock
(logged as a ``LockReclaimEvent``; NEVER skips validation/derive-verify).

Definition at line 316 of file pipeline.py.

Here is the call graph for this function:

Variable Documentation

◆ _ROADMAP_TABLES

tuple oc_chat.registry.regenerate.pipeline._ROADMAP_TABLES
protected
Initial value:
1= (
2 "roadmap_render_sections", "roadmap_item_dependencies", "roadmap_item_tracks",
3 "roadmap_items_v3", "roadmap_phases", "roadmap_tracks", "roadmap_versions",
4 "roadmap_eras",
5)

Definition at line 115 of file pipeline.py.

◆ _RUNTIME_TABLES

oc_chat.registry.regenerate.pipeline._RUNTIME_TABLES = frozenset({"agents", "rounds", "plans", "operation_log"})
protected

Definition at line 114 of file pipeline.py.