From 4d68dc89c7d43f65403d82a528090763dd06543e Mon Sep 17 00:00:00 2001 From: Shay Date: Wed, 20 May 2026 19:59:28 -0700 Subject: [PATCH] chore(generate): delete unreachable agenerate (#90) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes audit Finding 7 (2026-05-20). ``agenerate`` was a 43-line async generator at the bottom of ``generate/stream.py`` that reimplemented the walk loop without salience candidates, inner-loop admissibility, language candidates, rotor admissibility, margin mode, trajectory recording, vault recall scoring, or admissibility tracing — every capability the sync ``generate()`` has accrued since ADR-0022. Caller audit: * ``ChatRuntime.achat`` / ``ChatRuntime.arespond`` call the sync ``generate()`` under ``asyncio.to_thread`` semantics (the explicit comment in ``achat`` documents this: "the underlying call is still synchronous CPU-bound work"). * No production code, eval, demo, or test references ``agenerate``. * Re-exported in ``generate/__init__.py`` but only as a public name, never consumed. The function was therefore reachable only by accident — any caller wiring it would silently get a walk that ignores every ADR added since ADR-0022. CLAUDE.md's "small, load-bearing PRs" doctrine explicitly disfavors maintaining diverged reimplementations of the core loop as a future hook. Removed: * ``async def agenerate`` (43 lines) from ``generate/stream.py``. * ``agenerate`` from the ``generate/__init__.py`` star import and ``__all__``. If a real async walk path becomes necessary later (e.g. once ``achat`` needs genuine off-thread execution), the right shape is a thin ``asyncio.to_thread`` wrapper over the real ``generate()`` — not a parallel reimplementation. Verification: * ``ripgrep agenerate`` — zero remaining references in the repo. * ``core test --suite cognition`` — 120/0/1. * ``core test --suite smoke`` — 67/0. * ``core test --suite runtime`` — 19/0. --- generate/__init__.py | 3 +-- generate/stream.py | 45 -------------------------------------------- 2 files changed, 1 insertion(+), 47 deletions(-) diff --git a/generate/__init__.py b/generate/__init__.py index 03207c4b..6a9a5db2 100644 --- a/generate/__init__.py +++ b/generate/__init__.py @@ -13,7 +13,7 @@ from .dialogue import ( propose_dialogue, trajectory_blade, ) -from .stream import generate, agenerate +from .stream import generate from .surface import SentenceAssembler, SentencePlan, assemble as assemble_surface __all__ = [ @@ -23,7 +23,6 @@ __all__ = [ "FrameSlot", "Proposition", "PropositionFrame", - "agenerate", "blade_alignment", "classify_dialogue_blade", "generate", diff --git a/generate/stream.py b/generate/stream.py index 56b3360b..a4f51a70 100644 --- a/generate/stream.py +++ b/generate/stream.py @@ -638,48 +638,3 @@ def generate( admissibility_trace=tuple(admissibility_trace), region_was_unconstrained=region_was_unconstrained, ) - - -async def agenerate( - state: FieldState, - vocab, - persona, - max_tokens: int = 128, - vault=None, - recall_top_k: int = 3, -): - current = state - recent_nodes = deque([state.node], maxlen=_RECENT_WINDOW) - stop_nodes = frozenset( - idx for token in _STOP_TOKENS - if (idx := _try_index(vocab, token)) is not None - ) - for _ in range(max_tokens): - current, _hits_applied = _recall_state( - _voiced_state(current, persona), - vault, - recall_top_k, - ) - word, word_idx = _nearest_next( - vocab, - current.F, - current.node, - recent_nodes=tuple(recent_nodes), - stop_nodes=stop_nodes, - ) - yield _articulate(vocab, word) - - A = vocab.get_versor_at(current.node) - B = vocab.get_versor_at(word_idx) - V = word_transition_rotor(A, B) - - current = propagate_step(current, V) - current = FieldState( - F=current.F, - node=word_idx, - step=current.step, - holonomy=current.holonomy, - energy=current.energy, - valence=current.valence, - ) - recent_nodes.append(word_idx)