oc_chat
Loading...
Searching...
No Matches
seed_142_ingest Namespace Reference

Classes

class  MigrationReport

Functions

str _one_line (object text, int max_len=240)
str _iso_date (object value)
str _sanitize_id (str raw, MigrationReport report)
str _derive_purpose (object title, object prose, MigrationReport report)
dict[str, str] phase_title_map (Path roadmap_md)
Registry ingest_oracle (Path roadmap_dir, Path db_path)
tuple[dict, dict] _deps_and_tracks (sqlite3.Connection conn, MigrationReport report)
list _depends_on (str item_id, dict deps, dict sanitized)
bool _needs_promotion (sqlite3.Row row, dict deps)
None _write (Path out_dir, str rel, rc.RegistryModel model, str body="")
MigrationReport emit_source (Path db_path, Path out_dir, Path roadmap_md)
list _sub_rows (sqlite3.Connection conn, str phase_code)
None _emit_phases (conn, out_dir, titles, deps, tracks, sanitized, report)
None _emit_items (conn, out_dir, deps, tracks, sanitized, report)
str _reconcile_child_status (str item_id, str status, bool parent_done, MigrationReport report)
object _priority (object value)
str _promotion_reason (sqlite3.Row row, dict deps)

Variables

 _ISO_DATE_RE = re.compile(r"(\d{4}-\d{2}-\d{2})")
 _PHASE_HEADER_RE
 _ID_OK_RE = re.compile(rc.ID_RE)
dict _PRIORITIES = {"critical", "high", "medium", "lower"}
str _DEFAULT_DATE = "2026-06-02"

Detailed Description

The v3.38 binary -> AuthoredSource seed migration (Plan 142 P1.7, §9 / §5.8).

Purpose
-------
Ingest the live ``ROADMAP-v3.38*`` four-file set into a worktree-local store
(the oracle), then EMIT the per-record ``oc_chat/roadmap/source/**`` tree: 14
top-level phases as ``Phase`` records (sub-phases nested as ``sub_phases`` or
promoted to ``phases/<code>/<sub_id>.md`` per §5.6), non-phase items as
``RoadmapItem`` records, plus the era/tracks/version — backfilling a non-empty
``purpose`` for every phase + item (AC §8.22) and sanitising legacy ids/dates.

Responsibilities
----------------
- ``ingest_oracle(roadmap_dir, db)`` — build the oracle store.
- ``emit_source(db, out_dir, roadmap_md)`` — write the canonical source tree;
  return a migration report (counts, promotions, id/date sanitisations).

Diagnostics
-----------
Domain: OC_CHAT.MAIN
Levels:
    L2 - migration lifecycle
    L3 - per-entity emission
    L4 - per-record sanitisation

Contracts
---------
- Deterministic: identical inputs -> identical source bytes.
- Never writes outside ``out_dir``; the oracle DB is worktree-local + temporary.
- Every emitted record validates against the P1.1 / P1.4 models.

Dependencies
------------
- oc_diagnostics (structured debug logging via _dbg)
- oc_chat.registry.regenerate (imported for the contracts bootstrap it runs)
- option_c_registry_contracts (the record models, SCHEMA_VERSION, ID_RE and TERMINAL_STATUSES for the emitted source tree)
- oc_chat.registry (Registry - the oracle registry over the SQLite backend)
- oc_chat.registry.backends.sqlite (SQLiteBackend and RegistrySeed - the worktree-local oracle store)
- oc_chat.registry.regenerate.promoted (PromotedItem - the record for a sub-phase promoted to its own file)
- oc_chat.registry.roadmap.ingest (ingest_corpus - ingests the v3.38 four-file set into the oracle)
- oc_chat.registry.source.canonical (format_record_text - writes each emitted record canonically)

Function Documentation

◆ _depends_on()

list seed_142_ingest._depends_on ( str item_id,
dict deps,
dict sanitized )
protected

Definition at line 175 of file seed_142_ingest.py.

Here is the caller graph for this function:

◆ _deps_and_tracks()

tuple[dict, dict] seed_142_ingest._deps_and_tracks ( sqlite3.Connection conn,
MigrationReport report )
protected

Definition at line 153 of file seed_142_ingest.py.

Here is the caller graph for this function:

◆ _derive_purpose()

str seed_142_ingest._derive_purpose ( object title,
object prose,
MigrationReport report )
protected
Non-empty single-line ≤240 purpose: prose first sentence -> title (AC §8.22).

Definition at line 112 of file seed_142_ingest.py.

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

◆ _emit_items()

None seed_142_ingest._emit_items ( conn,
out_dir,
deps,
tracks,
sanitized,
report )
protected

Definition at line 294 of file seed_142_ingest.py.

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

◆ _emit_phases()

None seed_142_ingest._emit_phases ( conn,
out_dir,
titles,
deps,
tracks,
sanitized,
report )
protected

Definition at line 258 of file seed_142_ingest.py.

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

◆ _iso_date()

str seed_142_ingest._iso_date ( object value)
protected

Definition at line 96 of file seed_142_ingest.py.

Here is the caller graph for this function:

◆ _needs_promotion()

bool seed_142_ingest._needs_promotion ( sqlite3.Row row,
dict deps )
protected
§9 3c: promote only on item-specific data the nested form cannot hold —
description >240, a (non-inherited) priority, or dependencies. The inherited
parent track + the global ``v3.38`` version stamp are NOT triggers (they are
classified dedup drops, not per-item data).

Definition at line 183 of file seed_142_ingest.py.

Here is the caller graph for this function:

◆ _one_line()

str seed_142_ingest._one_line ( object text,
int max_len = 240 )
protected

Definition at line 91 of file seed_142_ingest.py.

Here is the caller graph for this function:

◆ _priority()

object seed_142_ingest._priority ( object value)
protected

Definition at line 322 of file seed_142_ingest.py.

Here is the caller graph for this function:

◆ _promotion_reason()

str seed_142_ingest._promotion_reason ( sqlite3.Row row,
dict deps )
protected

Definition at line 326 of file seed_142_ingest.py.

Here is the caller graph for this function:

◆ _reconcile_child_status()

str seed_142_ingest._reconcile_child_status ( str item_id,
str status,
bool parent_done,
MigrationReport report )
protected
A done parent's non-terminal child is reconciled to ``deferred`` (it was
deferred when the milestone shipped) — preserves the done milestone signal
while satisfying the done-parent⇒children-terminal invariant (AC §8.50).
Flagged for operator review (§9 3b).

Definition at line 311 of file seed_142_ingest.py.

Here is the caller graph for this function:

◆ _sanitize_id()

str seed_142_ingest._sanitize_id ( str raw,
MigrationReport report )
protected
Map a legacy id to the ASCII id shape (en/em-dash -> '-', illegal -> '_').

Definition at line 101 of file seed_142_ingest.py.

Here is the caller graph for this function:

◆ _sub_rows()

list seed_142_ingest._sub_rows ( sqlite3.Connection conn,
str phase_code )
protected

Definition at line 250 of file seed_142_ingest.py.

Here is the caller graph for this function:

◆ _write()

None seed_142_ingest._write ( Path out_dir,
str rel,
rc.RegistryModel model,
str body = "" )
protected

Definition at line 191 of file seed_142_ingest.py.

Here is the caller graph for this function:

◆ emit_source()

MigrationReport seed_142_ingest.emit_source ( Path db_path,
Path out_dir,
Path roadmap_md )
Emit the canonical source tree from the oracle store; return the report.

Definition at line 197 of file seed_142_ingest.py.

Here is the call graph for this function:

◆ ingest_oracle()

Registry seed_142_ingest.ingest_oracle ( Path roadmap_dir,
Path db_path )

Definition at line 135 of file seed_142_ingest.py.

◆ phase_title_map()

dict[str, str] seed_142_ingest.phase_title_map ( Path roadmap_md)

Definition at line 127 of file seed_142_ingest.py.

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

Variable Documentation

◆ _DEFAULT_DATE

str seed_142_ingest._DEFAULT_DATE = "2026-06-02"
protected

Definition at line 78 of file seed_142_ingest.py.

◆ _ID_OK_RE

seed_142_ingest._ID_OK_RE = re.compile(rc.ID_RE)
protected

Definition at line 76 of file seed_142_ingest.py.

◆ _ISO_DATE_RE

seed_142_ingest._ISO_DATE_RE = re.compile(r"(\d{4}-\d{2}-\d{2})")
protected

Definition at line 71 of file seed_142_ingest.py.

◆ _PHASE_HEADER_RE

seed_142_ingest._PHASE_HEADER_RE
protected
Initial value:
1= re.compile(
2 # OCT-LINT: disable=no_hardcoded_secrets reason="Seed migration constants + placeholder slot are not secrets"
3 r"^#\s+PHASE\s+(?P<code>M\S+)\s*[—-]\s*(?P<title>.+?)\s*$", re.MULTILINE
4)

Definition at line 72 of file seed_142_ingest.py.

◆ _PRIORITIES

dict seed_142_ingest._PRIORITIES = {"critical", "high", "medium", "lower"}
protected

Definition at line 77 of file seed_142_ingest.py.