Repository navigation
Description
What
Add stream_validate() to the Requirement class in mellea/core/requirement.py (class at line 104):
async def stream_validate(
self, backend, ctx, chunk: str
) -> PartialValidationResult:
return PartialValidationResult(success="unknown")Why
validate() (line 143) operates on complete output. Streaming validation needs per-chunk processing with different semantics: incremental input, tri-state result, and stateful accumulation across calls within a single attempt.
The method is named stream_validate, not avalidate. In mellea, the a-prefix means "async version of the same operation" — this is a different operation and should be clearly distinct.
In Phase 1, requirements receive chunks as plain strings passed by the streaming orchestrator. They never touch the MOT stream directly. Stateful requirements maintain their own incremental state across stream_validate calls (e.g. a running counter, an incremental parser). The streaming orchestrator clones each requirement (copy(req)) before every attempt, so streaming state is isolated to the clone and the original is never mutated.
The default is safe for all existing requirements. ALoraRequirement and LLMaJRequirement need no changes — they return "unknown" on every chunk and receive the full output via validate() at stream end.
Returning "pass" from stream_validate() does not short-circuit final validation in Phase 1. The orchestrator always calls validate() at stream end for any requirement that did not return "fail" — "pass" mid-stream is informational only.
Acceptance criteria
-
stream_validate(self, backend, ctx, chunk: str) -> PartialValidationResultexists onRequirementwith the default returningPartialValidationResult(success="unknown") -
ALoraRequirementandLLMaJRequirementwork correctly with the default — no override required - Unit tests in
test/core/:- Default
stream_validatereturns"unknown"for any chunk - A stateful subclass (e.g. counts bullet points) accumulates state correctly across multiple
stream_validatecalls - The same subclass starts from a clean state on a fresh clone — confirms orchestrator clone pattern works
- Default
- Google-style docstring on
stream_validate()stating: (a) default returns"unknown"; (b) returning"pass"is informational in Phase 1 and does not skip finalvalidate(); (c) implementations may accumulate state onself— the orchestrator clones the requirement before each attempt so state does not bleed across retries; (d) mutable container fields should be reassigned not mutated in place to be safe under shallow copy
Activity
[-]feat(core): add stream_validate() and reset() to Requirement[/-][+]feat(core): add stream_validate() to Requirement[/+]planetf1 commentedon Apr 24, 2026
Clarification: no
reset()in Phase 1. The title previously mentionedreset()— this has been removed. State isolation is handled entirely by the orchestrator cloning requirements (copy(req)) before each attempt, consistent with howvalidate()already works atrequirement.py:178. No lifecycle hook needed.The docstring on
stream_validate()should note the shallow-copy caveat: mutable container fields (e.g.self._buffer = []) are shared by reference undercopy(). Implementations should reassign (self._buffer = self._buffer + [chunk]) rather than mutate in place (self._buffer.append(chunk)), or override__copy__for proper isolation.feat: add stream_validate() hook to Requirement (generative-computing…
feat: add stream_validate() hook to Requirement (generative-computing…
feat: add stream_validate() hook to Requirement (generative-computing…
fix(core): fix stream_validate docstring and add missing stateful tests
feat: add stream_validate() hook to Requirement (generative-computing…
fix(core): fix stream_validate docstring and add missing stateful tests
fix(core): stream_validate receives a single chunk, not accumulated text
fix(stdlib): stream_with_chunking passes one chunk per stream_validat…
feat: add stream_validate() hook to Requirement (generative-computing…
fix(stdlib): stream_with_chunking passes one chunk per stream_validat…
fix(stdlib): address jakelorocco review feedback on stream_with_chunking
feat(stdlib): add stream_with_chunking() with per-chunk validation (g…
feat: add stream_validate() hook to Requirement (generative-computing…
feat(stdlib): add stream_with_chunking() with per-chunk validation (g…