Skip to content

P2: token discipline — schema caps, output contracts, CLAUDE.md - #43

Merged
alanshurafa merged 5 commits into
masterfrom
claude/wf-p2-discipline
Jul 5, 2026
Merged

P2: token discipline — schema caps, output contracts, CLAUDE.md#43
alanshurafa merged 5 commits into
masterfrom
claude/wf-p2-discipline

Conversation

@alanshurafa

Copy link
Copy Markdown
Owner

Phase 2 of the workflow-upgrade plan (plan @ e6db065).

What changed (3 commits)

  • skills/dev-review/schemas/review-verdict.json — machine-checked caps: issues.maxItems: 5, maxLength on all free text (summary 320, per-issue fields 240, iteration_notes 600). The two frozen copies (root schemas/, runners/codex-ps/schemas/) untouched (0 diff); the F-2 drift-guard sim reworked to the new invariant: frozen pair byte-identical + cap-free, runtime copy a strict superset with caps.
  • lib/co-evolution.sh:830-965validate_review_verdict enforces the same caps in BOTH the jq and jq-less branches; an over-cap verdict takes the existing invalid-verdict path (never passed downstream).
  • skills/dev-review/templates/review-prompt-{opus,codex}.md — output contracts (summary ≤40 words, ≤5 one-line file:line issues, no pasted file contents); dev-review/codex/dev-review.sh:632 inline compose prompt caps plan body ≤120 lines (composition has no template file — deviation noted).
  • skills/codex-build/SKILL.md — wake gate reads dev-review-status.sh --json only, never raw logs.
  • CLAUDE.md — Token Discipline section (return contracts, grep-before-read, noisy-op isolation, escalation ladder, 4-part delegation template), inserted after Model Routing.
  • tests/review-verdict-schema-simulation.sh — 5→23 scenarios.

Verification — 23/23 schema sim (stash-proof: pre-change, the 6 cap scenarios ACCEPT oversized verdicts; post-change REJECT); quick suite 25/25; pr-emitter 12/12; code-proposer 16/16; codex-ps zero diff. Live smoke: codex exec --output-schema with the capped schema → accepted, conformant verdict returned.

Skipped by design: PEL --budget preflight wire-up — it's a USD spend cap, not a token estimator; nothing trivial to surface.

🤖 Generated with Claude Code

alanshurafa and others added 3 commits July 5, 2026 19:17
An unbounded verifier verdict (many issues, a wall-of-text summary) is a
failed task even when correct, but nothing enforced that: oversized
verdicts sailed through validate_review_verdict and downstream. Add caps
to the live runtime schema (issues.maxItems=5; summary/iteration_notes/
per-issue-field maxLength) and mirror them shell-side so a cap-violating
verdict takes the existing invalid-verdict path — the claude verifier
seat has no --output-schema, so the CLI check alone would not catch it.
The frozen PS-runner schema pair (schemas/ + runners/codex-ps/) stays at
the loose F-2 shape; the drift guard is reworked to assert that split
(frozen pair identical, runtime a strict superset) and to pin the caps
in both the jq and jq-less validator branches.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Belt to the schema's braces: even where output is structured, the model
does better when the prompt states the budget up front. Verifier prompts
now spell out summary <=40 words, <=5 one-line file:line issues, and no
pasted file contents; the composer prompt caps the plan body at <=120
lines so a sprawling plan is a signal to cut scope, not write more.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Give the return-size contracts, working style, and delegation template a
home in CLAUDE.md so agents inherit them, and make the codex-build wake
gate explicit that it reads dev-review-status.sh --json only — the raw
compose/execute/review logs are noise, not the interface, and pulling
them into the gate's reasoning is the token blow-up the discipline exists
to prevent.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@alanshurafa alanshurafa closed this Jul 5, 2026
@alanshurafa alanshurafa reopened this Jul 5, 2026
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8d69f60a1d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/co-evolution.sh
Comment on lines +962 to +965
if (( ${#summary} > MAX_SUMMARY_LEN )); then
printf 'summary exceeded the %s-character cap' "$MAX_SUMMARY_LEN"
return 1
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Enforce all caps in the jq-less validator path

When jq is unavailable, the new fallback branch only counts issue severities and checks summary; after this check it returns success without enforcing the 240-character caps for file/line_range/description/suggestion or the 600-character iteration_notes cap that the schema and jq branch now require. I verified the fallback path by shadowing command -v jq: a REVISE verdict with a 300-character issues[0].description is accepted, so jq-less installs can still pass wall-of-text verifier output into the revise loop.

Useful? React with 👍 / 👎.

Both P2 and P3 added a section at the same anchor (Model Routing was
the EOF section when both branched), which left the PR unmergeable and
silently suppressed all pull_request CI runs. Order: Model Routing ->
Token Discipline -> Interactive vs Pipeline Boundary.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@alanshurafa
alanshurafa merged commit f8b4f1b into master Jul 5, 2026
6 checks passed
@alanshurafa
alanshurafa deleted the claude/wf-p2-discipline branch July 5, 2026 23:41
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