+ """
+ elif decision == "skip":
+ body = f"""
+ SKIP
+ {escape(run['verdict'].get('reason', ''))}
+ """
+ else:
+ body = "\n".join(cell_html(cells[g], owners, cells[g] is selected) if g in cells
+ else f' '
+ for g in GATES)
+ return f"{head}\n{body}\n "
+
+
+def clock_html(runs):
+ writes = [run for _, run in runs if run["verdict"]["decision"] == "write"]
+ asked = sum(run["verdict"]["decision"] == "ask" for _, run in runs)
+ week = (f'
')
+ took = ""
+ for run in writes:
+ times = run.get("times", {})
+ try:
+ start, end = (datetime.fromisoformat(times[k].replace("Z", "+00:00")) for k in ("received", "proposed"))
+ except (KeyError, AttributeError, ValueError):
+ continue
+ n = str(len(run["gates"]))
+ line = (f"one {KINDS[run['source']['kind']][2]} became {plural(n, 'draft')} for "
+ f"{plural(str(len({g.get('owner_role') for g in run['gates'].values()})), 'owner')}")
+ seconds = int((end - start).total_seconds())
+ took = (f'\n
\n
{seconds}s
\n'
+ f'
{line}
\n
')
+ label = f"{seconds} seconds: {line}"
+ break
+ else:
+ label = "This week"
+ return f' {took}\n {week}\n '
+
+
+def quote_where(folder, claim_words):
+ for number, line in enumerate((folder / "snapshot.md").read_text(encoding="utf-8").split("\n"), 1):
+ if check.find_run(check.words(line), claim_words) >= 0:
+ return f"Snapshot, line {number}"
+ return "Snapshot"
+
+
+def slip_html(folder, cell, owners):
+ run = cell.run
+ claims = {c["id"]: (n, c["quote"]) for n, c in enumerate(run["claims"], 1)}
+ rows = []
+ for index, line in enumerate(shown_lines((folder / "gates" / cell.gate / "draft.md").read_text(encoding="utf-8"))):
+ ids = " ".join(str(claims[c][0]) for c in line.claims if c in claims)
+ quotes = "".join(f'
"{escape(claims[c][1])}"
'
+ f'
{quote_where(folder, check.words(claims[c][1]))}
'
+ for c in line.claims if c in claims)
+ title = " is-title" if index == 0 and line.mark.startswith("#") else ""
+ rows.append(f"""
{escape(line.text)}{''.join(ref(claims, c, root) for c in line.claims)}
"
+
+
+def post_page(owners, title, root, current, main, nav_links, script=""):
+ pages = [("What is new", nav_links.get("blog")), ("Changelog", "changelog/index.html"),
+ ("FAQ", "faq/index.html"), ("Social", "social/index.html")]
+ nav = "\n".join(f' {label}'
+ for label, href in pages if href)
+ return Template((SITE / "post.html").read_text(encoding="utf-8")).substitute(
+ title=escape(title), company=escape(owners.get("company", "")), root=root, nav=nav, main=main, script=script)
+
+
+def blog_page(folder, cell, owners, also, nav_links):
+ run = cell.run
+ claims = {c["id"]: (n, c["quote"]) for n, c in enumerate(run["claims"], 1)}
+ lines = shown_lines((folder / "gates/blog/draft.md").read_text(encoding="utf-8"))
+ title = next((line.text for line in lines if line.mark == "# "), run["source"]["title"])
+ body = "\n".join(" " + sentence(line, claims) for line in lines if line.mark != "# ")
+ cited = list(dict.fromkeys(c for line in lines for c in line.claims if c in claims))
+ kind = KINDS[run["source"]["kind"]][0]
+ where = (f'{kind}' if run["source"].get("link") else kind)
+ sources = "\n".join(f"""
""" for c in cited)
+ links = [f'the {label}' for gate, page, label in
+ (("changelog", "changelog", "changelog"), ("faq", "faq", "FAQ")) if gate in also]
+ via_also = f'\n Also in {" and ".join(links)}' if links else ""
+ role = run["gates"]["blog"].get("owner_role", "")
+ name = owners.get("roles", {}).get(role, "")
+ main = f"""
{escape(str(run['verdict'].get('tier') or 'Launch').capitalize())}, arrived {when(run['source'].get('received'), '%A at %H:%M')}
+
{escape(title)}
+
+
+
+{body}
+
+
+
+
+ {escape(cell.stamp.capitalize())}
+ Blog post · approved by {escape(name)}, {escape(role.capitalize())}{via_also}
+
"""
+
+
+def faq_entries(folder, run):
+ claims = {c["id"]: (n, c["quote"]) for n, c in enumerate(run["claims"], 1)}
+ groups = []
+ for line in shown_lines((folder / "gates/faq/draft.md").read_text(encoding="utf-8")):
+ if line.mark == "## ":
+ groups.append((re.sub(r"^Q:\s*", "", line.text), []))
+ elif groups:
+ groups[-1][1].append(line)
+ return "\n".join(f"""
+
{escape(question)}
+
+{chr(10).join(' ' + sentence(line, claims) for line in answer)}
+
+
""" for n, (question, answer) in enumerate(groups, 1))
+
+
+COPY_SCRIPT = """"""
+
+
+def social_card(folder, run):
+ lines = shown_lines((folder / "gates/social/draft.md").read_text(encoding="utf-8"))
+ text = "\n".join(f"
{escape(line.text)}
" for line in lines)
+ return f"""
+
{escape(run['source']['title'])}
+
+{text}
+
+
+
"""
+
+
+def write(path, text):
+ path.parent.mkdir(parents=True, exist_ok=True)
+ path.write_text(text, encoding="utf-8", newline="\n")
+
+
+def build(runs_folder, notion_path, owners_path, skill, out):
+ owners = read_json(owners_path)
+ notion = read_json(notion_path)
+ runs = load_runs(runs_folder)
+ cells = {run["id"]: {g: resolve(folder, run, g, skill, notion) for g in run["gates"] if g in GATES}
+ for folder, run in runs}
+ selected = next((c for _, run in runs for c in cells[run["id"]].values() if c.tone in ("review", "back") and not c.held), None)
+ folders = {run["id"]: folder for folder, run in runs}
+
+ heads = "\n".join(f"""
-{chr(10).join(' ' + sentence(line, claims) for line in answer)}
+{chr(10).join(' ' + sentence(line, claims, linked=False) for line in answer)}
""" for n, (question, answer) in enumerate(groups, 1))
@@ -415,6 +419,7 @@ def build(runs_folder, notion_path, owners_path, skill, out):
slip=slip_html(folders[selected.run["id"]], selected, owners) if selected else ""))
published = {g: [c for _, run in runs for c in [cells[run["id"]].get(g)] if c and c.published] for g in GATES}
+ shutil.rmtree(out / "blog", ignore_errors=True)
nav_links = {"blog": f"blog/{published['blog'][0].run['id']}/index.html"} if published["blog"] else {}
for cell in published["blog"]:
also = {g for g, c in cells[cell.run["id"]].items() if c.published}
diff --git a/tests/test_site.py b/tests/test_site.py
index 9c2521f..f2f1499 100644
--- a/tests/test_site.py
+++ b/tests/test_site.py
@@ -24,6 +24,9 @@ def build(out, notion=None, runs=None):
return subprocess.run(args, capture_output=True, text=True, encoding="utf-8")
+VOID = {"area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "source", "track", "wbr"}
+
+
class Keyed(HTMLParser):
"""Collects the visible text of every element that carries data-key, and the text of the whole page."""
@@ -33,8 +36,9 @@ def __init__(self):
def handle_starttag(self, tag, attrs):
attrs = dict(attrs)
- if tag == "br":
+ if tag in VOID:
self.handle_data(" ")
+ return
if "data-key" in attrs:
self.open.append([attrs["data-key"], 0])
self.text[attrs["data-key"]] = ""
@@ -246,3 +250,29 @@ def test_a_passing_gate_with_no_notion_page_is_not_shown_as_drafted(tmp_path):
text, _, _ = parse(tmp_path / "out/index.html")
assert "NO PAGE YET" in text["cell/brief-seats/social"]
assert "DRAFTED" not in text["cell/brief-seats/social"]
+
+
+def test_the_text_reader_closes_a_keyed_element_that_holds_a_line_break():
+ parser = Keyed()
+ parser.feed('
A B
C
')
+ assert squash(parser.text["a"]) == "A B"
+ assert squash(parser.text["b"]) == "C"
+
+
+def test_a_rebuild_removes_a_blog_page_whose_gate_is_no_longer_published(tmp_path):
+ out = tmp_path / "out"
+ assert build(out).returncode == 0
+ assert (out / "blog/pr-csv/index.html").is_file()
+ notion = json.loads((FIXTURES / "notion.json").read_text(encoding="utf-8"))
+ notion["pr-csv/blog"]["status"] = "Rejected"
+ (tmp_path / "notion.json").write_text(json.dumps(notion), encoding="utf-8")
+ assert build(out, notion=tmp_path / "notion.json").returncode == 0
+ assert not (out / "blog/pr-csv").exists()
+
+
+def test_every_reference_on_a_published_page_reaches_a_target_on_that_page(site):
+ for page in ("blog/pr-csv/index.html", "changelog/index.html", "faq/index.html"):
+ html = (site / page).read_text(encoding="utf-8")
+ targets = set(re.findall(r'\bid="([^"]+)"', html))
+ anchors = re.findall(r'href="#([^"]+)"', html)
+ assert all(anchor in targets for anchor in anchors), (page, anchors, targets)
From 0adc809a3611a9ef22c91161a31bad6294d0e3ec Mon Sep 17 00:00:00 2001
From: Gabriel Abreu
Date: Mon, 16 Nov 2026 14:27:21 -0300
Subject: [PATCH 3/6] B-05 Fail the build with the page key when a Notion page
state is malformed
---
skills/launch-content/scripts/build_site.py | 11 ++++++++---
tests/test_site.py | 14 ++++++++++++++
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/skills/launch-content/scripts/build_site.py b/skills/launch-content/scripts/build_site.py
index 2fefb27..a5b60a4 100644
--- a/skills/launch-content/scripts/build_site.py
+++ b/skills/launch-content/scripts/build_site.py
@@ -102,9 +102,14 @@ def page_state(notion, key):
state = notion.get(key)
if state is None:
return None
+ if not isinstance(state, dict):
+ raise BuildError(f"{key} must be an object with status, round and url")
if state.get("status") not in STATUS:
raise BuildError(f"{key} has the Notion Status \"{state.get('status')}\", expected one of {', '.join(STATUS)}")
- return state
+ rounds = state.get("round", 1)
+ if isinstance(rounds, bool) or not isinstance(rounds, int) or rounds < 1:
+ raise BuildError(f"{key} has the round \"{rounds}\", expected a whole number")
+ return {"status": state["status"], "round": rounds, "url": str(state.get("url") or "")}
def resolve(folder, run, gate, skill, notion):
@@ -116,8 +121,8 @@ def resolve(folder, run, gate, skill, notion):
state = page_state(notion, f"{run['id']}/{gate}")
found = COUNTS.search(stamps[0]) if stamps else None
counts = " · ".join((plural(found[1], "line"), plural(found[2], "claim"), f"{found[3]} parts")) if found else ""
- url = state.get("url", "") if state else ""
- rounds = int(state.get("round", 1)) if state else 1
+ url = state["url"] if state else ""
+ rounds = state["round"] if state else 1
if failures:
return Cell(run, gate, "HELD BY THE CHECK", "back", False, counts, rounds, url, failures[0])
if state is None:
diff --git a/tests/test_site.py b/tests/test_site.py
index f2f1499..0893ed5 100644
--- a/tests/test_site.py
+++ b/tests/test_site.py
@@ -276,3 +276,17 @@ def test_every_reference_on_a_published_page_reaches_a_target_on_that_page(site)
targets = set(re.findall(r'\bid="([^"]+)"', html))
anchors = re.findall(r'href="#([^"]+)"', html)
assert all(anchor in targets for anchor in anchors), (page, anchors, targets)
+
+
+@pytest.mark.parametrize("entry, problem", [
+ ({"status": "Drafted", "round": "two"}, 'pr-csv/blog has the round "two", expected a whole number'),
+ ({"status": "Drafted", "round": None}, 'pr-csv/blog has the round "None", expected a whole number'),
+ ("Drafted", "pr-csv/blog must be an object with status, round and url"),
+])
+def test_a_malformed_notion_page_state_fails_the_build_with_its_key(tmp_path, entry, problem):
+ notion = json.loads((FIXTURES / "notion.json").read_text(encoding="utf-8"))
+ notion["pr-csv/blog"] = entry
+ (tmp_path / "notion.json").write_text(json.dumps(notion), encoding="utf-8")
+ result = build(tmp_path / "out", notion=tmp_path / "notion.json")
+ assert result.returncode == 1
+ assert f"FAIL {problem}" in result.stderr
From 2a495eb2d8e91c4cb047465882cee29fb0d0d960 Mon Sep 17 00:00:00 2001
From: Gabriel Abreu
Date: Mon, 16 Nov 2026 14:42:54 -0300
Subject: [PATCH 4/6] B-05 Label the board button Review in Notion and drop the
false undo line
---
skills/launch-content/scripts/build_site.py | 3 +--
tests/test_site.py | 6 ++++++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/skills/launch-content/scripts/build_site.py b/skills/launch-content/scripts/build_site.py
index a5b60a4..004fc23 100644
--- a/skills/launch-content/scripts/build_site.py
+++ b/skills/launch-content/scripts/build_site.py
@@ -261,8 +261,7 @@ def slip_html(folder, cell, owners):
{chr(10).join(first)}
{more}{ban}
"""
diff --git a/tests/test_site.py b/tests/test_site.py
index 0893ed5..2827898 100644
--- a/tests/test_site.py
+++ b/tests/test_site.py
@@ -195,6 +195,12 @@ def test_the_headline_counts_the_week(board):
assert "6 arrived" in page and "4 drafted · 1 asked · 1 skipped" in page
+def test_the_open_slip_sends_the_reader_to_notion_and_makes_no_undo_claim(board):
+ _, _, page = board
+ assert "Review in Notion" in page
+ assert "cannot be undone" not in page
+
+
def test_a_blog_page_shows_each_line_next_to_its_quote(site):
text, _, page = parse(site / "blog/pr-csv/index.html")
html = (site / "blog/pr-csv/index.html").read_text(encoding="utf-8")
From 227de89f2b80b8523e854ef0d19133154585332c Mon Sep 17 00:00:00 2001
From: Gabriel Abreu
Date: Mon, 16 Nov 2026 15:06:53 -0300
Subject: [PATCH 5/6] B-05 Read Draft lines and quotes with the merged Check's
plain text grammar
The merged Check replaced MARK and words with HEADING, plain_words and source_words. The builder now uses them, so a heading mark, a quote and a Snapshot line are read the way the Check reads them.
---
skills/launch-content/scripts/build_site.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/skills/launch-content/scripts/build_site.py b/skills/launch-content/scripts/build_site.py
index 004fc23..b4891a5 100644
--- a/skills/launch-content/scripts/build_site.py
+++ b/skills/launch-content/scripts/build_site.py
@@ -44,7 +44,7 @@ class BuildError(Exception):
class Shown(NamedTuple):
- """One Draft line as a reader sees it: its Markdown mark, its text without citations, and its claim ids."""
+ """One Draft line as a reader sees it: its heading mark, its text without citations, and its claim ids."""
mark: str
text: str
claims: tuple[str, ...]
@@ -70,11 +70,11 @@ def shown_lines(text):
lines = []
for raw in text.replace("\r\n", "\n").split("\n"):
line = raw.strip()
- if not line or check.PART.match(line):
+ if not line or check.PART.fullmatch(line):
continue
cited = check.CITATIONS.search(line)
body = (line[:cited.start()] if cited else line).strip()
- mark = check.MARK.match(body)
+ mark = check.HEADING.match(body)
lines.append(Shown(mark.group(0) if mark else "", body[mark.end():] if mark else body,
tuple(check.CLAIM_ID.findall(cited.group(0))) if cited else ()))
return lines
@@ -224,7 +224,7 @@ def clock_html(runs):
def quote_where(folder, claim_words):
for number, line in enumerate((folder / "snapshot.md").read_text(encoding="utf-8").split("\n"), 1):
- if check.find_run(check.words(line), claim_words) >= 0:
+ if check.find_run(check.source_words(line), claim_words) >= 0:
return f"Snapshot, line {number}"
return "Snapshot"
@@ -236,7 +236,7 @@ def slip_html(folder, cell, owners):
for index, line in enumerate(shown_lines((folder / "gates" / cell.gate / "draft.md").read_text(encoding="utf-8"))):
ids = " ".join(str(claims[c][0]) for c in line.claims if c in claims)
quotes = "".join(f'
""" for c in cited)
links = [f'the {label}' for gate, page, label in
From 1763c449beff2a3dcc9c3e45c1a6e4d816dad7be Mon Sep 17 00:00:00 2001
From: Gabriel Abreu
Date: Mon, 16 Nov 2026 15:21:35 -0300
Subject: [PATCH 6/6] B-05 Label owner claim quotes as Owner sources, test
round 0 and true
An owner claim's quote lives in its gate's owner_sources, as check.py
checks it, so the blog page and the board slip now say Owner sources
for it and skip the Snapshot search. Two malformed-state rows cover a
round of 0 and a round of true.
---
skills/launch-content/scripts/build_site.py | 13 +++++++++---
tests/test_site.py | 22 +++++++++++++++++++++
2 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/skills/launch-content/scripts/build_site.py b/skills/launch-content/scripts/build_site.py
index b4891a5..bbc5838 100644
--- a/skills/launch-content/scripts/build_site.py
+++ b/skills/launch-content/scripts/build_site.py
@@ -222,7 +222,11 @@ def clock_html(runs):
return f' {took}\n {week}\n '
-def quote_where(folder, claim_words):
+def quote_where(folder, claim):
+ """An owner claim's quote lives in the Owner sources of its gate, as check.py checks it; any other in the Snapshot."""
+ if "gate" in claim:
+ return "Owner sources"
+ claim_words = check.plain_words(claim["quote"])
for number, line in enumerate((folder / "snapshot.md").read_text(encoding="utf-8").split("\n"), 1):
if check.find_run(check.source_words(line), claim_words) >= 0:
return f"Snapshot, line {number}"
@@ -232,11 +236,12 @@ def quote_where(folder, claim_words):
def slip_html(folder, cell, owners):
run = cell.run
claims = {c["id"]: (n, c["quote"]) for n, c in enumerate(run["claims"], 1)}
+ places = {c["id"]: quote_where(folder, c) for c in run["claims"]}
rows = []
for index, line in enumerate(shown_lines((folder / "gates" / cell.gate / "draft.md").read_text(encoding="utf-8"))):
ids = " ".join(str(claims[c][0]) for c in line.claims if c in claims)
quotes = "".join(f'
'
for c in line.claims if c in claims)
title = " is-title" if index == 0 and line.mark.startswith("#") else ""
rows.append(f"""
@@ -296,11 +301,13 @@ def blog_page(folder, cell, owners, also, nav_links):
cited = list(dict.fromkeys(c for line in lines for c in line.claims if c in claims))
kind = KINDS[run["source"]["kind"]][0]
where = (f'{kind}' if run["source"].get("link") else kind)
+ places = {c["id"]: quote_where(folder, c) if "gate" in c else f"{where}, {quote_where(folder, c).lower()}"
+ for c in run["claims"]}
sources = "\n".join(f"""
""" for c in cited)
links = [f'the {label}' for gate, page, label in
diff --git a/tests/test_site.py b/tests/test_site.py
index 2827898..1dfeda0 100644
--- a/tests/test_site.py
+++ b/tests/test_site.py
@@ -216,6 +216,26 @@ def test_a_blog_page_shows_each_line_next_to_its_quote(site):
assert "Ready to post" in page and "approved by Sandbox owner" in page
+def test_an_owner_claim_names_the_owner_sources_on_the_blog_page_and_the_slip(tmp_path):
+ runs = tmp_path / "records"
+ shutil.copytree(FIXTURES / "records", runs)
+ record = json.loads((runs / "pr-csv/run.json").read_text(encoding="utf-8"))
+ record["claims"].append({"id": "c4", "gate": "blog", "quote": "CSV export ships to every plan this week."})
+ record["gates"]["blog"]["owner_sources"] = "CSV export ships to every plan this week."
+ (runs / "pr-csv/run.json").write_text(json.dumps(record), encoding="utf-8")
+ with (runs / "pr-csv/gates/blog/draft.md").open("a", encoding="utf-8") as draft:
+ draft.write("CSV export ships to every plan this week. [c4]\n")
+ assert build(tmp_path / "out", runs=runs).returncode == 0
+ page = (tmp_path / "out/blog/pr-csv/index.html").read_text(encoding="utf-8")
+ assert re.search(r'id="c4".*?
' in slip
+
+
def test_only_a_ready_to_post_or_posted_blog_gate_gets_a_page(site):
assert (site / "blog/pr-csv/index.html").is_file()
assert not (site / "blog/brief-seats").exists(), "a Drafted gate is not published"
@@ -287,6 +307,8 @@ def test_every_reference_on_a_published_page_reaches_a_target_on_that_page(site)
@pytest.mark.parametrize("entry, problem", [
({"status": "Drafted", "round": "two"}, 'pr-csv/blog has the round "two", expected a whole number'),
({"status": "Drafted", "round": None}, 'pr-csv/blog has the round "None", expected a whole number'),
+ ({"status": "Drafted", "round": 0}, 'pr-csv/blog has the round "0", expected a whole number'),
+ ({"status": "Drafted", "round": True}, 'pr-csv/blog has the round "True", expected a whole number'),
("Drafted", "pr-csv/blog must be an object with status, round and url"),
])
def test_a_malformed_notion_page_state_fails_the_build_with_its_key(tmp_path, entry, problem):