|
| 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) |
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)