oc_chat
Loading...
Searching...
No Matches
todo.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3# oc_chat/registry/render/roadmap/todo.py
4
5# OCT-LINT: disable=tests_exist reason="Covered by oc_chat/tests/registry/roadmap/test_render_living_set.py"
6"""
7The comprehensive V3 ``ROADMAP-EXTENDED.md`` renderer (Plan 142 P1.6, §6).
8
9Purpose
10-------
11Render the full historical record from the verified authored projection. This
12module — historically the retired ``ROADMAP-TODO.md`` renderer (the
13``roadmap_todo`` output is retired, AC §8.24) — is **repurposed** ([OP-2]) to
14produce ``ROADMAP-EXTENDED.md``: the same milestone table as the lean view plus
15sub-phase detail for **all** phases, the non-phase + git-workflow item tables,
16and a store-derived Versioning Notes section. Section order/selection are driven
17by the seeded ``roadmap_render_sections`` manifest for ``file_kind=
18'roadmap_extended'``.
19
20Responsibilities
21----------------
22- ``render(conn, *, source_hash, logical_state_hash, published=None)`` — the
23 EXTENDED view as a single byte-deterministic markdown string.
24
25Diagnostics
26-----------
27Domain: OC_CHAT.MAIN
28Levels:
29 L2 - render lifecycle
30 L3 - section counts
31 L4 - per-line assembly
32
33Contracts
34---------
35- Read-only; deterministic (no wall-clock).
36- Reads only INCLUDED §3.2 columns + the verified-derived version ``status``
37 (recomputed-and-verified at step-7) through the render guard.
38
39Dependencies
40------------
41- oc_diagnostics (structured debug logging via _dbg)
42- oc_chat.registry.render.roadmap._common (EXTENDED renderer id, generated header and footer, guarded query)
43- oc_chat.registry.render.roadmap.render_sections (EXTENDED file kind for the render-section manifest)
44- oc_chat.registry.render.roadmap.roadmap_main (shared manifest sections, version line, current pointer, legend and contents)
45- oc_chat.registry.render.roadmap.store_read (selected roadmap version)
46- oc_chat.registry.render.roadmap.sections (table cell escaping for the versioning notes)
47"""
48from __future__ import annotations
49
50import sqlite3
51from typing import Optional
52
53from oc_diagnostics import _dbg
54
55from oc_chat.registry.render.roadmap import roadmap_main
56from oc_chat.registry.render.roadmap import sections as section_render
57from oc_chat.registry.render.roadmap import store_read
59 RENDERER_EXTENDED,
60 build_generated_header,
61 generated_footer,
62 guarded_query,
63)
64from oc_chat.registry.render.roadmap.render_sections import FILE_KIND_EXTENDED
65
66_dbg("OC_CHAT.MAIN", "module", "loaded", 4)
67
68_TITLE = "# OC Chat Roadmap — Extended Record"
69_VERSION_HEADER = (
70 "| Version | Era | Bump | State | Released | Notes |\n"
71 "|---------|-----|------|-------|----------|-------|"
72)
73
74
75def render(
76 conn: sqlite3.Connection,
77 *,
78 source_hash: str,
79 logical_state_hash: str,
80 published: Optional[str] = None,
81 note_sections: Optional[list[str]] = None,
82) -> str:
83 """Render the comprehensive V3 ``ROADMAP-EXTENDED.md`` as deterministic bytes.
84
85 ``note_sections`` are the pre-rendered framing-note sections (Sources /
86 Reconciliation / Execution Order / Out Of Scope / Git Workflow) read from
87 ``source/notes`` by ``render_living_set`` — appended as an EXTENDED-only
88 appendix (the lean view never carries them); store-only ``render`` keeps no
89 source handle, so the caller passes them in.
90 """
91 func = "render"
92 header = build_generated_header(
93 source_hash=source_hash,
94 logical_state_hash=logical_state_hash,
95 renderer=RENDERER_EXTENDED,
96 )
97 version = store_read.selected_roadmap_version(conn)
98 body = roadmap_main._render_manifest_sections(conn, FILE_KIND_EXTENDED)
99 versioning = _versioning_notes(conn)
100 if versioning:
101 if body:
102 body.append("")
103 body.extend(versioning)
104 if note_sections:
105 if body:
106 body.append("")
107 body.extend(note_sections)
108 lines: list[str] = [
109 header,
110 "",
111 _TITLE,
112 "",
113 roadmap_main._version_line(version, published),
114 "",
115 # OCT-LINT: disable=no_hardcoded_secrets reason="Markdown labels + glyphs are presentation, not secrets"
116 "A complete index of every OC Chat roadmap phase, sub-phase, non-phase "
117 "item, and shipped version — the full historical record (see ROADMAP.md "
118 "for the lean working map).",
119 "",
120 "---",
121 "",
122 *roadmap_main._current_block(conn),
123 "",
124 "---",
125 "",
126 *roadmap_main.legend_lines(),
127 ]
128 toc = roadmap_main._toc(body)
129 if toc:
130 lines.extend(["", *toc])
131 lines.extend(["", *body])
132 lines.extend(["", *generated_footer("roadmap_extended")])
133 _dbg("OC_CHAT.MAIN", func, f"extended rendered version={version}", 2)
134 return "\n".join(lines).rstrip() + "\n"
135
136
137def _versioning_notes(conn: sqlite3.Connection) -> list[str]:
138 """Render the EXTENDED-only Versioning Notes table from ``roadmap_versions``."""
139 conn.row_factory = sqlite3.Row
140 rows = guarded_query(
141 conn,
142 # OCT-LINT: disable=no_hardcoded_secrets reason="Markdown labels + glyphs are presentation, not secrets"
143 "SELECT version_id, era_id, bump_kind, status, released_at, notes "
144 "FROM roadmap_versions ORDER BY version_id",
145 ).fetchall()
146 if not rows:
147 return []
148 lines = ["## Versioning Notes", "", _VERSION_HEADER]
149 for row in rows:
150 lines.append(
151 "| {version} | {era} | {bump} | {state} | {released} | {notes} |".format(
152 version=section_render.escape(row["version_id"]),
153 era=section_render.escape(row["era_id"]),
154 bump=section_render.escape(row["bump_kind"]),
155 state=section_render.escape(row["status"]),
156 released=section_render.escape(row["released_at"]),
157 notes=section_render.escape(row["notes"] or ""),
158 )
159 )
160 return lines
161
162
163__all__ = ["render"]
list[str] _versioning_notes(sqlite3.Connection conn)
Definition todo.py:137