threads_report.py¶
clew/propose/threads_report.py
Turn resolved spawn wrappers into gated entries, rejections and evidence.
build_section
SectionProposal clew.propose.threads_report.build_section(Context ctx, dict[str, Derived] known, dict[str, tuple[int,...]] refused, list[str] candidates, dict[str, list[CallSite]] by_callee)
Build the whole thread_patterns section from resolved candidates.
clew/propose/threads_report.py:48
Source · 43 lines
def build_section(
ctx: Context,
known: dict[str, Derived],
refused: dict[str, tuple[int, ...]],
candidates: list[str],
by_callee: dict[str, list[CallSite]],
) -> SectionProposal:
"""@brief Gate every candidate and assemble the section."""
entries: list[Entry] = []
rejections: list[Rejection] = [
Rejection(
name=name,
reason=(
"reachable definitions disagree on the entry-argument index "
f"({', '.join(str(i) for i in indices)}) — no single declaration is true"
),
evidence=_definition_lines(ctx, name),
)
for name, indices in sorted(refused.items())
]
for name in candidates:
outcome = _judge(ctx, name, known, by_callee.get(name, []))
if isinstance(outcome, Entry):
entries.append(outcome)
else:
rejections.append(outcome)
return SectionProposal(
name=SECTION_THREADS,
status=SectionStatus.PROPOSED if entries else SectionStatus.NO_CANDIDATES,
reason=_reason(ctx, entries, candidates),
checked={
"files_scanned": ctx.corpus.files_parsed,
"definitions": sum(len(v) for v in ctx.corpus.defs.values()),
"forwarding_candidates": len(candidates),
"proposed": len(entries),
},
entries=tuple(entries),
rejections=tuple(rejections),
notes=_NOT_DETECTED,
yaml_header=_HEADER if entries else (),
)