Skip to content

[Task]: split reviewing-before-merge into a compact root and lazy modules #451

Closed

Description

@sumithr

Status

In review through PR #653 with all checks green and review still required; keep this out of Ready until the PR merges.

Roadmap fields

Status: In review; Priority: P1; Size: M; Order: 3; Depends on: none

Validated against main on 2026-07-13. Still valid and not duplicated by #393/#450.

#393/#450 only prevents an oversized full-body response from failing. The shipped skill is still one 71,850-byte, 270-line SKILL.md with an estimated-token budget of 17,920, and it has no lazy modules. A real review therefore still loads the large checklist slice.

A June 2026 proof of concept split the skill into a ~1.9k-token routing root plus 14 cold references, kept the full suite green, and measured 31-79% savings across representative review paths (30.4% over one four-turn MCP probe). That branch/PR is no longer present locally or on GitHub, so this ticket owns recreating the design on current main.

Decision

Use the existing modules/*.md progressive-loading contract, not finer headings and not duplicated content.

  • Keep SKILL.md as the canonical routing root: frontmatter, Iron Law, execution order, module-routing table, verdict gate, and red flags needed on every review.
  • Move deep, conditionally used probe and evidence rules into cohesive modules/*.md files.
  • Every moved rule has one canonical source. Do not retain a second prose copy in SKILL.md.
  • Preserve stable user-visible terminology and output contracts. Module filenames/IDs are implementation details and may be chosen during the change.
  • Update eval assembly so each seed receives the root plus only the modules its declared scenario requires. Do not make the eval green by restoring the entire old body for every seed.

Required work

  1. Recreate the compact root and lazy modules from current main; do not resurrect the stale June text without reconciling changes merged since then.
  2. Extend cross-reference, packaging, installer/symlink, content-hash, and MCP resource tests so shipped module files are discoverable and included.
  3. Add a manifest contract test proving every routing-table module ID exists and every shipped module is reachable from the root.
  4. Add a content-integrity regression test for the load-bearing review rules moved out of the root.
  5. Replace the documented token-budget exception with measured root, per-module, and representative-path budgets.
  6. Run the complete reviewing-before-merge promptfoo matrix and the full Python suite.

Acceptance criteria

  • SKILL.md is at most 3,000 estimated tokens.
  • Each lazy module is at most 1,500 estimated tokens unless a narrowly documented exception has a measured reason.
  • A standard runtime-code review loads the root plus required modules at least 50% below the current 17,812-token full-body baseline.
  • At least three representative paths are measured separately: ordinary runtime change, test/eval-only change, and documentation/configuration change. Report exact root, module, and total estimates.
  • The zero-argument/full over-cap behavior from [Task]: full-body skill MCP tools can exceed the host per-response token cap (reviewing-before-merge) #393/fix: serve over-cap skill bodies as a progressive-loading pointer (#393) #450 remains compatible: it still returns an actionable progressive-loading pointer rather than an oversized body.
  • All existing reviewing-before-merge promptfoo evals pass without weakening rubrics, removing seeds, or loading every module unconditionally.
  • Tests fail for an unknown routing-table module, an orphan shipped module, a missing packaged module, and loss of a named load-bearing rule.
  • The full test suite and package/install smoke tests pass.

Boundaries

  • No new MCP tool is required; mode="module" already exists.
  • No duplicated/generated mirror of module prose.
  • No unrelated rewrite of the review discipline.
  • Per-load token measurements are the acceptance evidence; noisy whole-session totals are supplementary only.

Relationships

Activity

  1. added
    enhancement
    priority: later
    on Jun 21, 2026
  2. changed the title [-][Task]: split reviewing-before-merge's 9.2k-token checklist so progressive loading saves on actual use (#393 follow-up)[/-] [+][Task]: split reviewing-before-merge into a compact root and lazy modules[/+] on Jul 13, 2026
  3. added
    priority: next
    and removed
    priority: later
    on Jul 13, 2026
  4. sumithr commented on Sep 7, 2026

    @sumithr
    OwnerAuthor

    Drift reconciliation against main @ 2930a3a (2026-09-07), before implementing:

    • Body size. Issue says 71,850 bytes / 270 lines / 17,920 budget / "17,812-token full-body baseline". Live: 73,177 bytes / 275 lines / ~18,295 est. tokens, budget entry 18330 in tests/test_skill_md_token_budget.py. The ">=50% below the full-body baseline" AC will be measured against the live ~18,295 figure (a stricter bar), not the stale 17,812.
    • First real module consumer. No bundled skill ships a modules/ dir today; _index_modules, mode="module", the sumoqa://skills/{name}/modules/{id} resource and the 1,500-token module ceiling are all exercised only against tmp fakes. This PR makes reviewing-before-merge the first shipped consumer, so the "bundled skills have no modules/ dir yet" assumptions in tests/test_skill_manifest.py, tests/test_skill_resources.py and tests/test_skill_modules.py docstrings get retargeted.
    • Over-cap subject inverts. tests/test_skill_response_oversize.py::test_reviewing_before_merge_is_the_over_cap_skill and the assert over in test_no_served_full_body_exceeds_the_default_cap pin the review skill as the one over-cap body. After the split no bundled skill is over cap, so the [Task]: full-body skill MCP tools can exceed the host per-response token cap (reviewing-before-merge) #393/fix: serve over-cap skill bodies as a progressive-loading pointer (#393) #450 contract keeps its synthetic over-cap fixtures (boundary tests unchanged) and the library-wide test flips to "every bundled skill is served byte-for-byte, none degrade". The pointer behaviour itself is unchanged and still tested.
    • Docs that name the skill as the over-cap case (docs/SKILLS.md, docs/TOOLS.md x3, docs/ARCHITECTURE.md) and the DOCUMENTED_ROOT_BUDGET_EXCEPTIONS entry are updated in the same PR.
    • Eval assembly. All 28 skill-reviewing-before-merge*.yaml configs load skill_content: file://…/SKILL.md (the .ab.yaml controls keep their frozen fixtures/*-PRE-*.SKILL.md old bodies). Assembly moves to a shared promptfoo JS var function that concatenates the root plus only the modules each config/seed declares, per the Decision section.
  5. sumithr commented on Sep 9, 2026

    @sumithr
    OwnerAuthor

    finish-pr verification for PR #653 (head a095060)

    Acceptance criteria checked against the branch, not the PR text. Estimator is the shared (len(text)+3)//4.

    AC Met Evidence
    1. SKILL.md at most 3,000 est. tokens yes 2,996 measured on disk and served by the real server (mode="full" returned the body with estimated_tokens: 2996, hash equal to the manifest's); tests/test_skill_md_token_budget.py:43 entry 3000; tests/test_review_skill_modules.py:1078
    2. each module at most 1,500 yes 19 modules, largest coverage-ledger 1,475, smallest feedback-memory 475, each served by mode="module" with the same figure; tests/test_review_skill_modules.py:1086
    3. standard runtime review at least 50% below 17,812 yes (pinned path); see note pinned set root 2,996 + runtime-scope 755 + discovery-probes 1,384 + coverage-ledger 1,475 + unproven-escalation 1,359 = 7,969, 55.3% below 17,812; tests/test_review_skill_modules.py:1145. Real headless runs on the same runtime commit loaded 4, 7 and 11 modules (60.0%, 40.6%, 20.0% below); routing-row looseness filed as #659
    4. three paths measured separately yes runtime 7,969 (55.3%); test/eval-only 2,996 + 755 + 969 + 1,134 = 5,854 (67.1%); docs/config 2,996 + 755 + 763 = 4,514 (74.7%); REPRESENTATIVE_PATHS at tests/test_review_skill_modules.py:85, tests :1115-1174
    5. #393/#450 over-cap pointer still actionable yes real server with SUMO_QA_SKILL_RESPONSE_TOKEN_CAP=1000: zero-arg tool returned the pointer naming manifest, section and module routes; mode="full" returned oversize: true with available_modes and the section index; the module route then served runtime-scope at 755 tokens; tests/test_skill_response_oversize.py:94-147, :276
    6. promptfoo matrix passes, no weakened rubric / removed seed / all-modules load UNVERIFIED api.openai.com returned HTTP 429 credit_balance_exhausted on 2026-09-07, 2026-09-08 and again on 2026-09-09 (probed with the eval's gpt-4o-mini); the local tier is a relative instrument, not the merge gate. Static side holds: 28 configs diff removes no rubric line, no seed removed, no config declares all 19, A0 fixtures untouched, per-seed assembly verified under node (declared modules only, declared order, traversal and unknown ids rejected, no CR bytes)
    7. tests fail for unknown routing id / orphan module / missing packaged module / lost rule yes fault injection on the branch: ghost routing row (test_review_skill_modules.py:389 red), modules/orphan.md (:398 red), module on disk but excluded from the wheel via narrowed force-include (tests/test_wheel_packaging.py:100 red, 19 missing), gutted pinned body with header kept (:464 red), deleted rule line (:464 red); control green
    8. full suite + package/install smoke yes local on a095060: 3,728 passed, 5 skipped, 1 xfailed, 0 failed, 100% coverage; CI 33/33 on a095060 incl. pip/uvx/plugin install smoke on three OSes; mutation gate run 34354962379 passed, 0 survivors

    Behaviour ledger (4.7, observed on the real surface)

    Surface: branch wheel built with uv build --wheel from 192af4c (skill and source content identical through a095060), installed into a clean venv, driven by a headless claude -p --strict-mcp-config --allowedTools mcp__sumo-qa agent (model sonnet). Repo: this clone, reviewing real commits from main history.

    # Expected behaviour Real-surface call + input Observed output Met
    1 root served whole and under 3,000 sumo_qa_reviewing_before_merge() and sumo_qa_load_skill_context(mode="full") body (not a pointer), estimated_tokens 2996, routing table present with runtime-scope and discovery-probes as first rows yes
    2 every module loadable, under 1,500 mode="manifest" then mode="module" for all 19 ids 19 modules, 475 to 1,475, manifest and per-module figures identical, 23 tool calls yes
    3 runtime review loads root + routed modules review of f51dc78 (repo-map resolver hardening) via the router, root, mode="module" run 1: root + runtime-scope, discovery-probes, security-relevance, coverage-ledger = 7,116 (60.0% below); run 2: 7 modules = 10,572; run 3: 11 modules = 14,242; full risk-anchored verdict each time yes for the pinned set; over-loading tracked in #659
    4 test-only review loads the test-only path review of d28be6a (tests only) root + runtime-scope + test-only-diff = 4,720 (73.5% below); agent declined discovery-probes citing the test-only routing; verdict SAFE TO MERGE yes
    5 docs/config review loads the light path review of 2930a3a (release bump) root + runtime-scope + inventory-drift = 4,514 (74.7% below), second run also pulled coverage-ledger (5,957); verdict SAFE with three inventory-drift risks yes
    6 over-cap pointer remains actionable cap forced to 1,000 via env, zero-arg tool and mode="full" pointer text naming manifest/section/module routes; oversize: true envelope; module route served 755 tokens yes
    7 eval assembly loads root + declared modules only real assembler under node with the declared review_modules of three configs and six per-seed overrides assembled module headers equal the declarations in declared order; root-only 2,996; ../SKILL and unknown ids rejected; 0 CR bytes yes
    8 guard tests go red on the four fault classes in-place faults in the worktree, restored via git checkout all five injections red, control green (see AC7) yes

    Supporting slots:

    • real_repo: /Users/SumithRamsookbhai/Desktop/repos/apo/sumo-qa (primary checkout, real history) as the agent cwd; worktree sumo-qa-issue-451 for the build and fault injection.
    • real_surface: clean wheel install (19 modules present in the wheel) driven through the MCP tools by a headless agent; tool-call traces parsed from the stream-json transcripts.
    • existing_flow: base 2930a3a vs candidate wheel on two prompts via compare-mcp-versions: the router sent both to strengthen-test-coverage / sumo-qa-strengthening-tests with the identical first step quoted; sumo_qa_load_principles identical (7 ids); candidate used 312,662 tokens over 7 turns against 367,040 over 9.
    • evals: not run: OpenAI 429 credit_balance_exhausted on 2026-09-09.

    Review evidence: per-file sumo-qa-reviewing-before-merge pass over all 65 changed files on a095060 returned SAFE with no high or medium finding; six review-driven fix commits (3e5446a..a095060) closed the first pass's blockers and five codex rounds on the test guard; final codex round: no P1/P2. Zero open review threads.

  6. sumithr commented on Sep 9, 2026

    @sumithr
    OwnerAuthor

    Merge hold (2026-09-09): PR #653 stays open and unmerged until #660 lands. The OpenAI + promptfoo eval gate is retired; AC6 (the graded reviewing-before-merge matrix) will be run once under the new Claude judge/candidate gate from #660 and its result posted here, which unblocks the merge. Every other gate on #653 is green (CI 33/33 on a095060, mutation gate clean, per-file review SAFE, zero threads, behaviour ledger above).

  7. added 3 commits that reference this issue on Sep 25, 2026
    09f7498
    01762e1
    756d238
  8. sumithr commented on Sep 25, 2026

    @sumithr
    OwnerAuthor

    AC6 verified on the Claude gate (#660, #665)

    Command. SUMO_EVAL_BACKEND=claude bash tests/evals/promptfoo/run-eval.sh <config>, once for each of the 28 skill-reviewing-before-merge* configs, single pass.

    Model pair. Candidate claude-haiku-4-5, judge claude-opus-5, on the Claude subscription.

    Tree graded. PR #653's head a095060 with main merged in locally, as 6296f94. The branch was then rebased onto main and pushed as 92fb593. The skill, module, config and provider files are byte-identical between the graded tree and 92fb593; the only differences are the eval README and the token-budget test.

    Result. 92 cases, 90 passed, 0 provider or judge errors. About 1.3M tokens, $3.99 notional list price. That is costUSD at list price, not an invoice.

    Config Result
    19 plain configs all passed, 45 of 45 cases
    adversarial.ab A0 7/7, A1 7/7, B 7/7
    reviewing-before-merge.ab A0 3/3, A1 3/3, B 3/3
    verifier-evidence.ab pre-edit leg FAIL 0.00, post-edit leg PASS 0.90. Separates.
    unproven-escalation.ab pre-edit legs 1 of 2 fail, post-edit legs 2 of 2 pass. Separates on one seed.
    eval-validity.ab, feature-flow.ab, feedback-memory.ab, fence-parser.ab, runtime-scope.ab both legs pass. Does not separate.

    Every leg that loads this PR's skill passed. The two failing cases are control legs that are meant to fail.

    The seven controls that don't separate fail because their control legs pass too. Those legs read no skill, or a frozen fixtures/reviewing-before-merge-PRE-*.SKILL.md snapshot that is byte-identical to main, so the split cannot cause it. It is the same class of problem as the #679 run on main, and it is owned by #685. #665's criterion that all 7 controls hold is handed to #685 and not claimed here.

    The AC's static half holds on the branch. Seed counts are unchanged in all 28 configs. Config edits are limited to the skill var, review_modules, disableVarExpansion and comments, so no rubric was touched. No config loads every module.

    The promptfoo JSON reports, one per config, are retained on the maintainer's machine, outside the repo, because tests/evals/results/ is gitignored.

    Behaviour ledger (finish-pr 4.7), observed on 92fb593

    The branch wheel was installed into a clean venv. Each row was driven by a headless claude -p agent, claude-sonnet-5, restricted to the installed sumo-qa MCP server through --strict-mcp-config.

    # Expected behaviour (#451) Real-surface call + input Observed output Met
    1 Root SKILL.md <= 3,000 tokens sumo_qa_load_skill_context with skill sumo-qa-reviewing-before-merge, mode="full" estimated_tokens: 2996 yes
    2 Each module <= 1,500 tokens mode="manifest" 19 modules listed; heaviest coverage-ledger at 1475 yes
    3 Standard runtime review >= 50% below 17,812 real review of commit 41875b3, a heading-fence parser fix in src/ plus its test loaded root + runtime-scope 755, discovery-probes 1384, contract-and-fence-probes 1349, coverage-ledger 1475 = 7,958, 55% below yes
    4a Test/eval-only path measured real review of 92fb593, a test-only change root + runtime-scope, test-only-diff, surface-verifier, external-contract = 7,121, 60% below yes
    4b Docs/config path measured real review of a5f0ea0, README + docs root + runtime-scope, inventory-drift = 4,513, 75% below yes
    5 Zero-argument/full load stays actionable, never oversized sumo_qa_reviewing_before_merge with no args, and mode="full" returns the 2,996-token root with the 19-row module routing table naming the mode="module" fetch; no oversized body yes
    6 Unknown module is a clean failure mode="module", module="no-such-module" {"error": "Unknown module 'no-such-module' ...", "available_modules": [19 ids]} yes
    7 Modules load on demand mode="module", module="runtime-scope" module text, estimated_tokens: 755, content_hash present yes
    8 Evals pass under the gate the run above 90/92, both failures are control legs meant to fail yes
    9 Guard tests fail for unknown/orphan/missing/lost rule; suite + install smoke pass uv run pytest on 92fb593; CI 4,128 passed, 100% coverage; CI 33/33 incl. install/uvx/plugin smoke; mutation gate run 36123479862 passed yes

    All three review agents ended NOT SAFE for one stated reason: they were told not to run tests, and the skill will not issue a SAFE verdict without a fresh run. Each said its reading of the diff found no defect.

    real_repo: this clone. The three reviews ran against real commits in its history.

    existing_flow: the same agent, claude-haiku-4-5, called using_sumo_qa, sumo_qa_load_classifications and sumo_qa_load_skill_context for the preparing-for-work manifest on a clean install of this branch and of origin/main. All three outputs were byte-identical: 16,249, 2,297 and 2,687 chars.

    evals: the 28-config run above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai-taskenhancementpriority: nexttooling

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions