feat(ce-code-review): emit a schema'd envelope.json in headless mode#865
Open
gushecht wants to merge 1 commit into
Open
feat(ce-code-review): emit a schema'd envelope.json in headless mode#865gushecht wants to merge 1 commit into
gushecht wants to merge 1 commit into
Conversation
mode:headless is documented as the mode "for programmatic skill-to-skill invocation," but its only specified machine handoff is the prose text envelope, which callers must grammar-parse. The merged finding set already exists as structured data in-context after Stage 5; this serializes it. Adds envelope.json (merged findings + verdict + counts) under the run artifact dir, against a new references/envelope-schema.json. Additive: the prose envelope stays the primary human-facing handoff; an Envelope: line points callers at the JSON. Per-finding fields mirror findings-schema.json so the merge step populates them directly. The skill validates the file against the schema before emitting "Review complete", falling back to the degraded envelope on failure.
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
mode:headlessis documented as the mode "for programmatic skill-to-skill invocation" (SKILL.md §"Headless mode rules"), but its only specified machine handoff is the prose text envelope (§"Headless output format"). Programmatic callers must parse that prose with a grammar — header sentinel,Verdict:line,[P1][gated_auto -> …]finding lines, terminator — which breaks on cosmetic drift (a preamble line, trailing text on the header, a reworded section heading).The run-artifact directory already exists, but the structured data in it isn't a usable contract for the merged result:
{reviewer}.jsonfiles are pre-merge / pre-dedup / pre-gating;metadata.jsoncarries only run_id/branch/head_sha/verdict;So the post-merge, synthesized finding set — the thing a caller actually wants — is only emitted in a specified form as prose.
(Context: we consume
mode:headlessfrom a downstream CI reviewer and have repeatedly lost expensive reviews to prose-format mismatches; this is the upstream half of the fix.)Proposal
In headless mode, additionally write a machine-readable
<run-id>/envelope.jsoncontaining the merged finding set (post-Stage-5b), verdict, and counts, against a new publishedreferences/envelope-schema.json. Surface its path on a newEnvelope:line in the prose output.findings-schema.json— this serializes data you have, it isn't a new computation. Per-finding fields are lifted 1:1 fromfindings-schema.json(plus areviewerslist from the merge tier), so the field mapping is mechanical.Review complete; on failure it emits the existing degraded envelope rather than writing a malformed file.Changes
skills/ce-code-review/references/envelope-schema.json— new draft-07 schema for the merged envelope.skills/ce-code-review/SKILL.md— headless-mode rule, anEnvelope:line + formatting note in the output format, the field mapping in Step 4, and registration in Included References.Validation
bun test— 1395 pass / 0 fail (unchanged from base).bun run scripts/release/validate.ts— metadata in sync.Happy to adjust naming, schema shape, or whether this should extend to
autofix/interactivemodes too — wanted to keep the first cut minimal and headless-only.