Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem & who this helps
Engineers and automation pipelines using
client.knowledge.start_plan_implementation(plan_id)currently have to hand-roll polling aroundget_plan_implementation(implementation_id)until the attempt settles, while also validating the returned identity (id,plan_version,attempt), handling MCP tool refusals (isError) without retrying, checking layer validation states, and bounding total wait time across both synchronous and asynchronous (asyncio/ Trio) callers.Approach & design decisions
KnowledgeClientandAsyncKnowledgeClient(proofline/knowledge.py):wait_for_plan_implementation(implementation_id, *, timeout=300, plan_version=None, attempt=None, organization_id=None)on both sync and async knowledge clients, returning a frozenPlanImplementationOutcome(withLayerOutcomeandLayerValidation, exported fromproofline).wait_for_reviewsemantics: validatesimplementation_id(UUID),timeout,plan_version, andattemptbefore sending any request; polls with exponential backoff (5s -> 10s -> 20s -> 40s -> 60s) capped to the remaining wait budget; supportstimeout=0single-read checks; and works on bothasyncioand Trio viaanyio.sleep.structuredContent.data.idmatches the requestedimplementation_id(raisingurn:proofline:sdk:invalid-responseon mismatch or malformed metadata).plan_versionandattemptfromstart_plan_implementation: a mismatch ends the wait immediately on that read withstatus="INCOMPLETE", and missing pinned fields never produceVALIDATED.status="VALIDATED"only when top-level status isVALIDATED, layer metadata is present and non-empty, and every layer reportsVALIDATED; unrecognized statuses fail closed asINCOMPLETE.result,layers,layer,step, anderror_codeout ofrepr()so untrusted text is not dumped into diagnostic output.proofline/_mcp.py,proofline/knowledge.py):isError: True) end the wait immediately withstatus="REFUSED",is_error=True, optionalerror_code, and the rawKnowledgeResultintact.429and503) and MCP protocol errors propagate immediately without retry.httpx2.TimeoutExceptionin_mcp.pyasurn:proofline:sdk:timeoutso in-flight timeouts at the wait deadline cleanly returnTIMED_OUTwith the last observed result, while pre-deadline per-request timeouts still raiseProoflineError.Verification
tests/test_plan_implementation.pyexercising sync,asyncio, and Trio clients against the real loopback HTTP server: backoff/polling toVALIDATED, terminal statuses (VALIDATION_FAILED,REFUSED,FAILED,STOPPED), fail-closed layer checks, pinnedplan_version/attemptmismatch and missing fields, tool refusals (isError), HTTP429/503no-retry,timeout=0, response decoded at deadline, real in-flight deadline vs pre-deadline timeout, input validation, malformed payload rejection, andrepr()safety.python3 scripts/check.pylocally (generation check, operation/vocabulary contracts,ruff check,ruff format --check, strictmypy,pytestwith 332 passed, wheel + sdist builds, and installed-artifact smoke tests for both wheel and sdist) — all passed.