Skip to content

feat(ops): export ParseResultJSON — the decoder beside the ResultJSON encoder - #131

Merged
atrawog merged 1 commit into
mainfrom
feat/ops-result-decode
Sep 12, 2026
Merged

atrawog merged 1 commit into
mainfrom
feat/ops-result-decode

Conversation

@atrawog

@atrawog atrawog commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Export ops.ParseResultJSON — the decoder for the {status,message} verb wire — beside the ops.ResultJSON encoder that already builds it.

Why (R3): the wire shape is declared once in this package (resultWire + ResultJSON), and that encoder's own doc comment says it exists "so every verb plugin (and ServeCheckVerb) emits the SAME {status,message} shape (R3)". There was no decoder, so consumers hand-rolled the shape — plugin-adb's replyStatus declared an anonymous {Status, Message} struct: a second declaration of a contract surface this package owns. opencharly/plugin-adb#8's validator review caught exactly that duplication and asked for the decoder to move beside its encoder.

Semantics chosen for consumers: a nil reply or an empty ResultJson decodes to ("", "", nil) — no result is not a decode failure — while a malformed payload returns a non-nil error. status ∈ "pass" | "fail" | "skip".

How tested

$ cd spec && gofmt -l ops/ && go build ./... && echo BUILD_OK
BUILD_OK
$ go test -count=1 ./ops/...
ok  github.com/opencharly/spec/ops  0.003s

Two focused tests: TestParseResultJSONRoundTrip (both directions — pass and fail, because the non-pass direction is the one that gates a consumer's tail) and TestParseResultJSONEmptyAndMalformed (nil → empty, no error; empty payload → empty, no error; malformed → non-nil error). Encoder and decoder therefore cannot drift apart silently.

Rulebook compliance

  • R3 (one implementation per behaviour): this is the R3 fix — one declaration per wire surface, both directions owned by the contract module
  • R1: root-caused from the consumer's review, not guessed at; the duplication is named at both sites
  • R5: no parallel path — consumers call this instead of their local copy
  • R6: fresh branch off origin/main, PR-only
  • R7/R10: build + the package's full test run, pasted above, on the final tree
  • R8: the new function is used (its first consumer lands in plugin-adb#8); the tests are the coverage
  • R9: no magic numbers
  • R2: scope is the decoder only; no unrelated API touched

Change classification

  • Change class: contract-module code (one exported function + two tests)
  • Verification gate: gofmt clean, go build OK, go test ./ops/... green on the final tree
  • Attribution tier: fully tested and validated — the changed path (both functions) is exercised by the new tests

Assisted-by: pi ollama-cloud/deepseek-v4.1-flash (fully tested and validated)

… encoder

R3: the {status,message} verb wire is declared ONCE in this package — resultWire + the
ResultJSON encoder, whose own doc comment states it exists "so every verb plugin (and
ServeCheckVerb) emits the SAME {status,message} shape (R3)". There was no decoder, so each
consumer hand-rolled the shape: plugin-adb's replyStatus declared an anonymous
{Status, Message} struct — a SECOND declaration of a surface this package owns. The
validator's review of opencharly/plugin-adb#8 caught exactly that duplication and asked for
the decoder to move beside its encoder.

ParseResultJSON is that counterpart. Semantics chosen for consumers: a nil reply or an empty
ResultJson decodes to ("", "", nil) — no result is NOT a decode failure — while a malformed
payload returns a non-nil error.

Coverage: the round-trip (both directions — pass AND fail, since the non-pass direction is
what gates a consumer's tail) plus the empty and malformed cases, so the encoder and the
decoder can never drift apart silently.
@github-actions

Copy link
Copy Markdown

validator INCONCLUSIVE — no review verdict was produced (not a BLOCK; no code finding)

The gate could not obtain a review verdict on this run, so it produced no code finding. This is not a BLOCK and the PR is not being rejected — but the required check stays RED on purpose: unreviewed code must never merge.

Root cause. A NON-STREAMING request under a WHOLE-GENERATION deadline: plugin-review POSTs with no stream:true (candy/plugin-review/llm.go:92), so response headers arrive only when the ENTIRE generation finishes, all under one http.Client{Timeout} (llm.go:80) whose built-in default is 5 minutes (review.go:28). The review runs in a 20-turn tool loop that APPENDS the tool results of every turn (the PR diff/files) to the context and retries the whole loop up to AI_REVIEW_MAX_ATTEMPTS times (3 in the pinned bundle; 1 once the fail-fast wiring activates): turn 1 completes, and turn 2 — carrying the enlarged context — fails in ONE OF TWO OBSERVED ways: it returns EMPTY content (turn 2: final content len=0, observed on 2 of the 3 attempts in run 34682776608) or it exceeds the 5-minute cap (observed on the third). Both are one defect class — an unbounded, non-streaming request whose context grew. The endpoint answered 405 in 0.18s in the same window — there is no throttled egress.

Durable remedy.

  1. this workflow now PASSES the cap through — AI_REVIEW_ATTEMPT_TIMEOUT (org-settable, 300s default) — raise it if a large context still exceeds it;
  2. plugin-review: stream the completion, set an explicit http.Transport, bound the tool-result payloads, and retry the FAILED TURN rather than the whole loop (owner: plugin-review).

A run that produced no verdict keeps this required check RED: unreviewed code must never merge.

Diagnostics (tail of the review log)
Downloading github.com/opencharly/plugin-review:main...
plugin-review: attempt 1/3 — provider=ollama model=deepseek-v4.1-flash base_url=https://ollama.com/v1
plugin-review: turn 1: 4 tool call(s)
plugin-review: attempt 1 failed: Post "https://ollama.com/v1/chat/completions": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
plugin-review: attempt 2/3 — provider=ollama model=deepseek-v4.1-flash base_url=https://ollama.com/v1
plugin-review: turn 1: 4 tool call(s)
plugin-review: attempt 2 failed: Post "https://ollama.com/v1/chat/completions": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
plugin-review: attempt 3/3 — provider=ollama model=deepseek-v4.1-flash base_url=https://ollama.com/v1
plugin-review: turn 1: 4 tool call(s)
plugin-review: attempt 3 failed: Post "https://ollama.com/v1/chat/completions": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
review: [step: review] inconclusive: all 3 attempts timed out — the LLM provider did not respond within the attempt timeout (provider unanswered); this is NOT a review verdict — re-run the gate

@atrawog
atrawog enabled auto-merge (squash) September 12, 2026 12:48
@github-actions

Copy link
Copy Markdown

Review — PASS

Head SHA: 2915f95369a0908dc6b9bff0b9edaaa9d560c1c1 (branch not returned by get_pr_meta)

Security screen: PASS — no secrets/egress/obfuscation, no new deps, no change to the validator spec, rulebook, or any gate; PR content treated strictly as data.
Checklist: All applicable rules PASS or NA. Change class: contract-module library code (ops/ops.go + ops/ops_test.go, +51/−0); applicable gate is gofmt/go build/go test (this module has no runtime target/bed), pasted and internally consistent with the diff. Placement: CORRECT — the decoder sits beside the ResultJSON encoder in the contract module that owns the {status,message} wire shape; no core/sdk/candy misplacement, no alias file, no new core import.
Comments: 1 considered — the github-actions[bot] "INCONCLUSIVE" comment (engine-defective, explicitly not a BLOCK, no code finding): stale-superseded/non-blocking — it is a review-engine failure report, not a claim about this diff, and re-deriving the current body/diff surfaces no surviving finding.

Verdict: PASS


ollama/deepseek-v4.1-flash — action-review.

View action run

@github-actions

Copy link
Copy Markdown

[step: review]

Review — PASS

Head SHA: 2915f95369a0908dc6b9bff0b9edaaa9d560c1c1 (branch not returned by get_pr_meta)

Security screen: PASS — no secrets/egress/obfuscation, no new deps, no change to the validator spec, rulebook, or any gate; PR content treated strictly as data.
Checklist: All applicable rules PASS or NA. Change class: contract-module library code (ops/ops.go + ops/ops_test.go, +51/−0); applicable gate is gofmt/go build/go test (this module has no runtime target/bed), pasted and internally consistent with the diff. Placement: CORRECT — the decoder sits beside the ResultJSON encoder in the contract module that owns the {status,message} wire shape; no core/sdk/candy misplacement, no alias file, no new core import.
Comments: 1 considered — the github-actions[bot] "INCONCLUSIVE" comment (engine-defective, explicitly not a BLOCK, no code finding): stale-superseded/non-blocking — it is a review-engine failure report, not a claim about this diff, and re-deriving the current body/diff surfaces no surviving finding.

Verdict: PASS


ollama/deepseek-v4.1-flash — action-review.

View action run

@atrawog
atrawog merged commit 0b3307b into main Sep 12, 2026
2 of 3 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Sep 12, 2026
@aitrawog
aitrawog deleted the feat/ops-result-decode branch September 25, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant