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

Classes

class  BackfillReport

Functions

dict[str, str] parse_phase_sections (str roadmap_text)
dict[str, str] deliverable_items (str section_body)
str _capped (str text)
BackfillReport backfill (Path roadmap_md, Path source_dir)
int _main ()

Variables

 _PHASE_HEADER_RE = re.compile(r"^# PHASE (\S+) — (.+)$", re.MULTILINE)
 _BOUNDARY_RE = re.compile(r"^(# PHASE |## )", re.MULTILINE)
 _TRAILING_RULE_RE = re.compile(r"\n*-{3,}\s*$")
 _DELIV_ROW_RE = re.compile(r"^\|\s*(?P<id>[A-Za-z][\w.\-]*)\s*\|\s*(?P<item>.+?)\s*\|.*\|\s*$")
int _LINE240_MAX = 240

Detailed Description

Per-phase prose backfill (Plan 142 prose-preservation Phase 2, GATE2 step 1).

Purpose
-------
P1.7 seeded the roadmap ITEM SET into the registry but dropped the per-phase
PROSE — every ``# PHASE Mx`` section in the legacy
``oc_chat/roadmap/ROADMAP-v3.38.md`` (phase metadata + the full ``### Deliverables``
table with each item's *rich description + status provenance* + ``### Acceptance``)
was lost: the seeded ``phases/<code>.md`` records carry an EMPTY body and a few
``sub_phases`` descriptions degraded to bare-id stubs (e.g. ``M0.2``).

This tool restores them, byte-faithfully, mirroring the Phase-1 pattern (verbatim
section -> record body): for each ``# PHASE`` section it writes the verbatim
section body into the matching ``phases/<code>.md`` record BODY (which the P1.4
build already carries into ``roadmap_items_v3.prose`` via ``prose=body or None``,
so the EXTENDED render can emit it). It also replaces each ``description == id``
sub-phase stub with the real Item-column text from that phase's deliverables
table (single-lined, capped to the ``Line240`` contract).

No contract change: the Phase model is unchanged; only record BODIES (and the
handful of stub descriptions) are rewritten. Idempotent — re-running yields
identical bytes.

Responsibilities
----------------
- ``parse_phase_sections`` (split the legacy file on ``# PHASE`` headers),
  ``deliverable_items`` (id -> Item-column text), ``backfill`` (re-emit records),
  ``coverage`` (the per-phase / per-item map for the audit artifact).

Diagnostics
-----------
Domain: OC_CHAT.MAIN
Levels:
    L2 - backfill lifecycle
    L3 - per-phase section extraction
    L4 - per-record emission

Contracts
---------
- Deterministic; writes only ``source/phases/<code>.md`` records; never touches
  the live legacy roadmap; every rewritten record re-validates + re-canonicalises.

Dependencies
------------
- oc_diagnostics (structured debug logging via _dbg)
- oc_chat.registry.regenerate (imported for the contracts bootstrap it runs)
- oc_chat.registry.source.canonical (load_record and format_record_text - reads each phase record and re-emits it with the restored body)
- oc_chat.registry.source.scanner (scan_source_tree - finds the phase records)

Function Documentation

◆ _capped()

str seed_142_prose_backfill._capped ( str text)
protected
Single-line + cap to the ``Line240`` contract (whole-word trim).

Definition at line 132 of file seed_142_prose_backfill.py.

Here is the caller graph for this function:

◆ _main()

int seed_142_prose_backfill._main ( )
protected

Definition at line 175 of file seed_142_prose_backfill.py.

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

◆ backfill()

BackfillReport seed_142_prose_backfill.backfill ( Path roadmap_md,
Path source_dir )
Backfill every ``phases/<code>.md`` body from the legacy ``# PHASE`` sections.

Definition at line 141 of file seed_142_prose_backfill.py.

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

◆ deliverable_items()

dict[str, str] seed_142_prose_backfill.deliverable_items ( str section_body)
Map ``sub_id -> Item-column text`` from a phase section's deliverables table.

Definition at line 114 of file seed_142_prose_backfill.py.

Here is the caller graph for this function:

◆ parse_phase_sections()

dict[str, str] seed_142_prose_backfill.parse_phase_sections ( str roadmap_text)
Return ``{phase_code: verbatim_section_body}`` for every ``# PHASE`` section.

The body is everything after the header line up to the next ``# PHASE`` /
top-level ``## `` heading, with the inter-section ``---`` rule stripped.

Definition at line 96 of file seed_142_prose_backfill.py.

Here is the caller graph for this function:

Variable Documentation

◆ _BOUNDARY_RE

seed_142_prose_backfill._BOUNDARY_RE = re.compile(r"^(# PHASE |## )", re.MULTILINE)
protected

Definition at line 79 of file seed_142_prose_backfill.py.

◆ _DELIV_ROW_RE

seed_142_prose_backfill._DELIV_ROW_RE = re.compile(r"^\|\s*(?P<id>[A-Za-z][\w.\-]*)\s*\|\s*(?P<item>.+?)\s*\|.*\|\s*$")
protected

Definition at line 83 of file seed_142_prose_backfill.py.

◆ _LINE240_MAX

int seed_142_prose_backfill._LINE240_MAX = 240
protected

Definition at line 85 of file seed_142_prose_backfill.py.

◆ _PHASE_HEADER_RE

seed_142_prose_backfill._PHASE_HEADER_RE = re.compile(r"^# PHASE (\S+) — (.+)$", re.MULTILINE)
protected

Definition at line 77 of file seed_142_prose_backfill.py.

◆ _TRAILING_RULE_RE

seed_142_prose_backfill._TRAILING_RULE_RE = re.compile(r"\n*-{3,}\s*$")
protected

Definition at line 81 of file seed_142_prose_backfill.py.