Skip to content

Commit b4d6c8c

Browse files
Fix-forward: :code: false is the author withholding source, and I published it
The exec-lane builder ported in fe0d144 carried a defect the template seat found and corrected at 9b2ad49. It bit here, on the worst page. `.. exec::docs.home.video` carries `:code: false` — the author saying this module is plumbing for an embed, not documentation. My port published its source to /llms.txt, the site's most-read machine surface, inverting the usual asymmetry: the browser lane deliberately hides it, and the machine lane began serving it. Silently, because the browser kept looking right. AND MY "WIN" MEASURED THE DEFECT, WHICH IS THE PART I GOT MOST WRONG. I reported 15,349 -> 18,723 bytes as the video's content reaching agents, having claimed its "title, URL and id were invisible to every agent". That claim was FALSE. docs/home/home.md has published the title and the youtu.be link as an author-written markdown link since 3ebd507 (2026-08-23), a week before this session — so nothing a reader needed was ever missing. Every one of the 3,374 bytes I added was the withheld source. The number I offered as evidence of a fix was a measurement of the harm. Corrected to the seat's shape: read the directive's indented `:option:` lines; DEDUPE FIRST, because a directive already `.. source::`d for the same target has its code in the document and announcing it as withheld would be a false statement about the page; then `:code: false` emits a MARKER naming the module and why its source is absent — never a silent skip, since broken, hidden and absent must not look alike; otherwise expand. Measured after: home /llms.txt back to 15,438 (baseline + 89, the marker). Of 33 substantive lines in video.py, ZERO reach the machine document; the one line that appears is `import dash_mantine_components as dmc`, which is also in the paired, deliberately-published example.py. The paired exec still dedupes to exactly one `# File:` marker. Also from the same push: the test-client pin no longer accepts `headers=` as evidence of a User-Agent (`headers={"CF-IPCountry": "FR"}` names no lane), and tests/test_exec_lane.py now pins the withheld case both ways — the source absent AND the marker present. The refinement this leaves for the pairing axis, which I owe it after overstating the last one: an unpaired directive is a CANDIDATE, not a defect. Whether the content is actually absent is a second question, and whether it SHOULD be present is the author's, answered by `:code: false`. Verified: 309 -> 310 passed / 1 skipped / 0 failed; flake8 clean; smoke_test 81/81. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01P6tDZymsTt73Z4xFW1M5JX
1 parent fe0d144 commit b4d6c8c

3 files changed

Lines changed: 102 additions & 22 deletions

File tree

‎pages/markdown.py‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,34 @@ def exec_expansion(module_path: str) -> str:
249249
m = _EXEC_DIRECTIVE.match(line)
250250
if m:
251251
skip_options = True
252-
if exec_target_file(m.group(1)) not in paired:
252+
# `:code: false` is the AUTHOR saying this module is
253+
# plumbing for an embed, not documentation (muischeduler,
254+
# 2026-08-31 — 12 of its 34 directives carry it). Rendering
255+
# it into the machine lane publishes exactly what the
256+
# browser lane deliberately hides, inverting the usual
257+
# asymmetry, and silently: the browser keeps looking right.
258+
# This repo shipped that inversion on all three of its own
259+
# unpaired directives before the correction landed.
260+
# Skipped, but NOT silently — broken, hidden and absent must
261+
# not look alike, which is the whole lesson of this round.
262+
opts = []
263+
j = i
264+
while j < len(lines) and lines[j].strip().startswith(':'):
265+
opts.append(lines[j].strip())
266+
j += 1
267+
hidden = any(o.replace(' ', '').lower() == ':code:false' for o in opts)
268+
target = exec_target_file(m.group(1))
269+
if target in paired:
270+
# Dedupe wins over the withheld marker: the source IS in
271+
# this document, via `.. source::`, so announcing it as
272+
# withheld would be a false statement about the page.
273+
pass
274+
elif hidden:
275+
out.append(
276+
f'\n<!-- component rendered from {target}; source withheld '
277+
f'by `:code: false` -->\n'
278+
)
279+
else:
253280
out.append(exec_expansion(m.group(1)))
254281
continue
255282
out.append(line)

‎tests/test_exec_lane.py‎

Lines changed: 59 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@
4141
4242
Some prose.
4343
44+
.. exec::docs.home.example
45+
46+
More prose.
47+
"""
48+
49+
# `:code: false` is the author saying "this module is plumbing for an
50+
# embed, not documentation" (muischeduler). Rendering it into the machine
51+
# lane publishes what the browser lane deliberately hides — and silently,
52+
# because the browser keeps looking right. This repo shipped that inversion
53+
# on all three of its own unpaired directives before the correction.
54+
HIDDEN = """# Page
55+
4456
.. exec::docs.home.example
4557
:code: false
4658
@@ -50,7 +62,6 @@
5062
PAIRED = """# Page
5163
5264
.. exec::docs.home.example
53-
:code: false
5465
5566
Source code:
5667
@@ -64,7 +75,6 @@
6475
DIFFERENT_TARGET = """# Page
6576
6677
.. exec::docs.home.example
67-
:code: false
6878
6979
.. source::docs/home/video.py
7080
"""
@@ -98,16 +108,19 @@ def _needle() -> str:
98108
"""
99109
src = (REPO / "docs" / "home" / "example.py").read_text()
100110
for line in src.split("\n"):
101-
# PORTED anchor: upstream looks for a top-level `def`, which its
102-
# example modules have. This fork's showcase convention is a
103-
# module-level `component = ...` with no functions at all, so the
104-
# anchor is the first top-level STATEMENT of either shape. Still
105-
# read at run time and never a literal — that property is the point.
106-
if line.startswith("def ") or (
107-
line[:1].isalpha() and " = " in line and not line.startswith(" ")
108-
):
111+
if line.startswith("def "):
109112
return line
110-
pytest.fail("docs/home/example.py has no top-level statement to anchor on")
113+
# PORTED FALLBACK: this fork's showcase modules export a module-level
114+
# `component = dmc.Stack(...)` and define no functions at all, so
115+
# upstream's `def `-only search finds nothing here. The fork-invariant
116+
# form is "first top-level statement" — still read at run time, never a
117+
# literal, which is the property that matters. Multi-line-string openers
118+
# (`X = """...`) are skipped: their first line is a poor anchor.
119+
for line in src.split("\n"):
120+
if (line[:1].isalpha() and " = " in line and not line.startswith(" ")
121+
and '"""' not in line and "'''" not in line):
122+
return line
123+
pytest.fail("example.py has no top-level statement to anchor the pin on")
111124

112125

113126
def test_the_needle_is_really_in_the_module():
@@ -122,7 +135,28 @@ def test_an_unpaired_exec_renders_its_module_source(app_module):
122135
assert _needle() in out, "the exec'd component's code never reached the prose"
123136
assert "```python" in out
124137
assert ".. exec::" not in out, "the raw directive line survived into the prose"
125-
assert ":code:" not in out, "the directive's option line was left behind as prose"
138+
139+
140+
def test_a_code_false_directive_withholds_the_source_but_says_so(app_module):
141+
"""The author's signal is honoured, and the gap is VISIBLE.
142+
143+
Skipping silently would leave the same shape as the defect: a machine
144+
document with nothing where a component is. Broken, hidden and absent
145+
must not look alike.
146+
"""
147+
out = _expand(HIDDEN)
148+
assert _needle() not in out, "`:code: false` source was published to the machine lane"
149+
assert "source withheld" in out and "example.py" in out, (
150+
"the withheld component left no trace at all"
151+
)
152+
# Line-exact, not a substring: the marker itself quotes `:code: false`,
153+
# so a substring assertion matches the pin's own output. That is the
154+
# third time in this round a check matched prose ABOUT the thing it was
155+
# asked to find — the UA grep flagged its own comment, and before that a
156+
# naive count read fenced documentation as defects.
157+
assert not any(ln.strip() == ":code: false" for ln in out.split("\n")), (
158+
"the directive's option line was left behind as prose"
159+
)
126160

127161

128162
def test_a_paired_exec_renders_once_not_twice(app_module):
@@ -194,21 +228,26 @@ def test_every_exec_in_this_repos_docs_reaches_the_machine_lane(client, app_modu
194228
continue
195229
target = REPO / (m.group(1).strip().replace(".", "/") + ".py")
196230
body = md.read_text()
197-
# PORTED: this fork's frontmatter QUOTES its values
198-
# (`endpoint: "/attribution"`), so the raw capture built
199-
# `/"/attribution"/llms.txt` and every page looked like a
200-
# mechanism-4 leak. Strip the quotes rather than the pin.
201-
endpoint = re.search(r"^endpoint:\s*(\S+)", body, re.M).group(1)
202-
endpoint = endpoint.strip("\"'")
231+
# `.strip("\"'")` — a fork whose frontmatter QUOTES its values
232+
# (`endpoint: "/attribution"`) otherwise builds
233+
# `/"/attribution"/llms.txt`, gets "llms.txt not available", and
234+
# sees every page reported as a mechanism-4 leak: a wall of false
235+
# failures on a pin that is otherwise right (leaflet, 2026-08-31).
236+
endpoint = re.search(r"^endpoint:\s*(\S+)", body, re.M).group(1).strip("\"'")
203237
url = f"{endpoint.rstrip('/')}/llms.txt"
204238
doc = client.get(url).text
205239
anchors = [
206240
ln for ln in target.read_text().split("\n")
207241
if ln.startswith("def ") or ln.startswith("component = ")
208242
]
209243
assert anchors, f"{target} has no anchor line to check"
210-
assert anchors[0] in doc, (
211-
f"{url} does not carry {target.name}'s code — mechanism 4"
244+
# Either the code reached the lane, or the author withheld it with
245+
# `:code: false` and the document SAYS SO. What is not acceptable
246+
# is silence, which is the defect this whole file exists for.
247+
withheld = "source withheld" in doc and target.name in doc
248+
assert anchors[0] in doc or withheld, (
249+
f"{url} carries neither {target.name}'s code nor a withheld "
250+
f"marker for it — mechanism 4"
212251
)
213252
checked += 1
214253
assert checked >= 3, f"only {checked} exec directives walked; the sweep found nothing"

‎tests/test_nav_contract.py‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,21 @@ def _client_names_a_ua(src: str, var: str) -> bool:
422422
if re.search(re.escape(var) + r"\.environ_base\b[^\n]*HTTP_USER_AGENT", src):
423423
return True
424424
calls = [c for m in _REQUEST_METHODS for c in _calls(src, f"{var}.{m}")]
425-
return bool(calls) and all("headers=" in c for c in calls)
425+
return bool(calls) and all(_names_a_ua(c) for c in calls)
426+
427+
428+
def _names_a_ua(call: str) -> bool:
429+
"""`headers=` is NOT evidence of a User-Agent (muischeduler, 2026-08-31).
430+
431+
A call passing `headers={"CF-IPCountry": "FR"}` satisfies a `headers=`
432+
grep and names no lane at all — this repo had exactly that one, and its
433+
mutation check stayed green until the pin asked for the UA specifically.
434+
A fleet-wide grep on `headers=` reports clean trees that are not.
435+
"""
436+
return any(
437+
token in call
438+
for token in ("HTTP_USER_AGENT", "user_agent=", "User-Agent", "USER_AGENT")
439+
)
426440

427441

428442
def test_every_test_client_user_names_headers():

0 commit comments

Comments
 (0)