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

Show on the map →

Called by propose_thread_patterns

Calls _definition_lines, _judge, _reason

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 (),
    )

Activity · 9 steps
lines 56–56entries: list[Entry] = []lines 57–67rejections: 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()) ]lines 68–68◇ for name in candidateslines 69–69outcome = _judge(ctx, name, known, by_callee.get(name, []))lines 70–70◇ if isinstance(outcome, Entry)lines 71–71entries.append(outcome)lines 72–72elselines 73–73rejections.append(outcome)lines 74–88return 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 (), )

Requirements

REQ-DDB-CONFIG-001