fix(description): write a spec point only where a YAML reader reads it verbatim

K3-19 c, repaired before delivery on its own measurement. The first R761
build from de7849e wrote 2 024 descriptions, and PyYAML's safe_load refused
the frontmatter of 217 of those concepts -- every one carrying ": " -- where
the same document had parsed with 1 refusal of 2 761 before the key existed.

`inbox._yaml_plain` is checked where the description is written, so a direct
`render_inbox_concept` caller is held to it as well as `okf build`: no leading
YAML indicator, no ": ", no " #", no trailing ":", no tab or line break.
Decided by rule rather than by a parser, because the one runtime dependency is
the guard; over the 2 024 measured values the rule and PyYAML agree on every
one (217 refused, 0 refused that PyYAML reads, 0 kept that it does not).
Omitted rather than quoted or cleaned: a quoted value comes back from the
line-oriented readers here WITH its quotes, and a cleaned one is a sentence
the source does not carry.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Kjell Tore Guttormsen 2026-09-11 03:48:26 +02:00
commit 77e7caba2e

View file

@ -213,9 +213,11 @@ def render_inbox_concept(
frontmatter[policy.offset_key] = _render_flow_list([str(offset) for offset in segment.span]) frontmatter[policy.offset_key] = _render_flow_list([str(offset) for offset in segment.span])
if segment.parent_id is not None: if segment.parent_id is not None:
frontmatter["parent"] = segment.parent_id frontmatter["parent"] = segment.parent_id
if segment.description is not None: if segment.description is not None and _yaml_plain(segment.description):
# The SOURCE's words, carried by the plan. Absent is the source # The SOURCE's words, carried by the plan, and written only where
# saying nothing -- never a summary derived from the title. # they read back verbatim. Absent is the source saying nothing, or
# saying it in a form this line cannot carry -- never a summary
# derived from the title, and never a cleaned-up one.
frontmatter["description"] = segment.description frontmatter["description"] = segment.description
if policy.adjudication_key is not None: if policy.adjudication_key is not None:
# The per-entry verdict IS the discriminator. A plan-level # The per-entry verdict IS the discriminator. A plan-level
@ -398,6 +400,30 @@ def _flow_expressible(value: str) -> bool:
return bool(value) and not any(char in value for char in f"{_FLOW_TERMINATORS}\n\r") return bool(value) and not any(char in value for char in f"{_FLOW_TERMINATORS}\n\r")
# What a YAML reader takes as syntax at the START of a plain scalar.
_YAML_INDICATORS = frozenset("-?:,[]{}#&*!|>'\"%@`")
def _yaml_plain(value: str) -> bool:
"""Whether `value` reads back verbatim as a plain scalar in a block mapping.
MEASURED ON R761: 217 of 2 024 first spec points carry `": "`, and PyYAML's
`safe_load` refused exactly those 217 concepts' frontmatter. Decided by
rule rather than by a parser, because this package's one runtime
dependency is the guard -- and over those 2 024 values the rule and PyYAML
agree on every one: 217 refused, 0 refused that PyYAML reads, 0 kept that
it does not.
"""
return (
bool(value)
and value[0] not in _YAML_INDICATORS
and ": " not in value
and " #" not in value
and not value.endswith(":")
and not any(char in value for char in "\t\n\r")
)
def _screened(gate: Gate, value: str | None) -> str | None: def _screened(gate: Gate, value: str | None) -> str | None:
"""A value read from the DOCUMENT and persisted outside its screened body. """A value read from the DOCUMENT and persisted outside its screened body.