Skip to content

feat(context): bundle whole catalogues and enter security-testing through one bundled call - #829

Merged
sumithr merged 7 commits into
mainfrom
feat/issue-802-bundle-routed-skills
Oct 5, 2026
Merged

sumithr merged 7 commits into
mainfrom
feat/issue-802-bundle-routed-skills

Conversation

@sumithr

@sumithr sumithr commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

Bundle mode gains a catalogues= parameter, and the router enters the security-testing skill through one bundled call that carries the skill body, the security standards and rules, and the techniques catalogue. Only the security family is wired, because it is the only family where a real-session measurement showed the bundle saving tokens. If that bundle call returns an error, the router falls back to the security-testing skill tool.

Related issue

Refs #802 (child of epic #508). #802 stays open for the families that are not wired; the measurement is on the issue.

Changes

  • catalogues= on bundle mode (src/sumo_qa/skill_manifest.py, src/sumo_qa/server.py): accepts techniques, principles, classifications and approaches. Each part is byte-identical to its single loader. An unknown name returns an error envelope listing the valid names. The oversize error now also suggests dropping catalogues and loading each with its own loader. The capability profile gate from main still runs before any bundle is built.
  • Router (skills/sumo-qa-deciding-approach/SKILL.md): its own loads are classifications and approaches. For security-testing, the router's handoff is one bundle call made instead of the skill tool, never both; on an error it calls the skill tool. The routing table and steps match.
  • Security-testing skill (skills/sumo-qa-security-testing/SKILL.md step 2): uses its context when it arrived in one bundle call, and otherwise loads standards, rules and techniques with the single loaders (entry by another skill's handoff, the Skill tool, or the symlinked skill).
  • Conformance (src/sumo_qa/conformance.py, scripts/live_first_hop.py, debug capture): a successful body-carrying bundle call for a routed skill counts as entry into that skill, applied once to every check (expected entry skill, required/forbidden tools, required-one-of, the first hop, the sumo-qa call ban). A bundle recorded as an error does not count: the debug capture records the error flag, and the live harness reads it from the matched tool result. include_body is coerced the way the server coerces it.
  • Audit (scripts/audit_context_budget.py, pyproject.toml): workflows take optional loaders, catalogues and handoff keys; loader names are trimmed and validated. A security-testing workflow is measured: 8 calls per-loader against 5 bundled. The full-profile tools/list budget is 12,200: main's external-skill tools left 5 tokens of headroom and the catalogues= parameter adds 66. The core budget is unchanged.
  • Docs: docs/TOOLS.md, docs/SKILLS.md, docs/DEVELOPMENT.md, docs/ARCHITECTURE.md, tests/scenarios/CONFORMANCE.md.

How it was verified

  • Premise measurement (compare-mcp-versions --review-mode, haiku, one run per family; full table on [Task]: Load every routed skill's working context through one bundled call #802): security 330,484 to 261,127 tokens (21% fewer, 8 to 4 turns, equivalent answer), so wired. Planning was cheaper but did not call the bundle; test-writing, answering and strategising were more expensive. None of those is wired.
  • Behaviour (branch wheel in a clean venv, headless haiku through the MCP tools, on the final head): a security-testing request routes through the router to one bundle call in 4 turns (main: 6 to 7 turns through the skill tool and separate loaders), and the answer uses its rules and techniques; entry through the skill tool still loads standards, rules and techniques; each catalogues= part is byte-identical to its single loader; an unknown name returns the error envelope; the conformance validator scores the real captures as entry and an errored bundle as not entered. Router error fallback, wording test on haiku: 0 of 5 fell back without the clause, 4 of 5 with it, and the normal handoff still made the bundle call in 5 of 5.
  • Audit (context budget: OK): security-testing bundle 4,478 of 4,600; tools/list core 9,261 of 9,400 and full 12,161 of 12,200; security testing workflow re-sent estimate 78,101 per-loader against 43,331 bundled.
  • Evals (Claude pair, judge claude-opus-5-5): skill-deciding-approach.yaml 5/5; skill-deciding-approach.ab.yaml full-skill leg 9/9 (the no-skill and catalogue-only controls fail as designed); skill-security-testing.yaml 5/5.
  • Suite: pre-push hook on the final head 6,289 passed, 8 skipped, 1 xfailed, 100% coverage; the scoped mutmut hook passed. CI and the Linux mutation gate on the final head are in the proof comment.
  • Review: sumo-qa per-file review and /code-review high on the full diff and on every fix delta, before and after the rebase onto main. Real defects in conformance visibility, error handling and the router's error path were found and fixed.

Not changed, deliberately: rebuilding a transcript from a debug capture still raises on a truncated input.json. Reading it as empty arguments was tried and rejected in review, because it would let a misrouted bundle score as a pass; failing loudly on a corrupt capture is the safer behaviour for a conformance gate.

Checklist

  • PR title follows Conventional Commits
  • Tests pass locally (pytest) and lint/type checks are green (pre-commit run --all-files, python -m mypy)
  • Added or updated tests covering the change
  • Updated the relevant docs in this same PR
  • No breaking changes (or they are called out above)

…ough one bundled call

Bundle mode takes a catalogues= parameter (techniques, principles,
classifications, approaches); each part is byte-identical to its single
loader, and an unknown name returns an error envelope listing the valid ones.

The router now enters sumo-qa-security-testing with one
sumo_qa_load_skill_context bundle carrying its body, its security_change
standards and rules, and the techniques catalogue, instead of the skill tool
plus three loaders. The context-budget audit reports that workflow per-loader
(8 calls) vs bundled (5 calls) and caps its bundle.

Per-family premise check (compare-mcp-versions --review-mode, haiku, one
run each, same prompt on both sides): only the security family used the
bundle and came out cheaper (330,484 to 261,127 tokens, 8 to 4 turns,
equivalent answer). Planning, answering and strategising runs never called
the bundle; test-writing called it and cost 22% more. Those families stay on
their per-loader path.

Refs #802
…and keep the router contract consistent (Refs #802)

Conformance reads a bundle-mode sumo_qa_load_skill_context call that
carries a routed skill's body as entry into that skill, in routing, the
first-hop chain and tool clauses; manifest, module and body-less bundle
loads are not entry. The server captures sumo_qa_load_skill_context calls
with their args, so a SUMO_QA_DEBUG_DIR capture of the bundled handoff
satisfies the entry contract.

The router's catalogue contract names the security-testing bundle as its
one handoff exception (the bundle replaces the skill tool, never both),
and security-testing step 2 uses bundled context when it arrived and the
single loaders otherwise. The oversize bundle error also names dropping
catalogues, and the context-budget audit strips and validates each
workflow loader, reporting an unknown one as a named FAIL.
…mapping to every check (Refs #802)

The server's debug capture records whether a sumo_qa_load_skill_context
call returned an error envelope, and conformance reads it: a bundle recorded
as an error (unknown id, oversize) is not entry; a call with no result
information is judged on its args. Entry names are mapped once per
transcript, so routing, the first-hop chain, required and forbidden tools,
required_one_of and forbid_sumo_qa_calls all see a body-carrying bundle as
both its own tool and the routed skill's tool. include_body is read the way
the server's bool parameter coerces it.
…arameter (Refs #802)

Rebased onto main, the full profile's tools/list measured 12,161 estimated tokens against main's 12,100 budget: main's external-skill tools (#845) left 5 tokens of headroom and the catalogues= parameter adds 66. The core budget is unchanged.
…try bundle errors (Refs #802)

The router's security handoff said to call the bundle instead of the skill tool and never both, with no instruction for an error envelope. Given an oversize error, haiku followed the error's own hint in 5 of 5 reps and retried with include_body=False plus load_techniques, so the skill body never arrived. With the fallback clause 4 of 5 reps called sumo_qa_security_testing, and the normal handoff still made the bundle call in 5 of 5.
@sumithr
sumithr force-pushed the feat/issue-802-bundle-routed-skills branch from 7b8dc66 to 602d3fb Compare October 5, 2026 10:53
@sumithr

sumithr commented Oct 5, 2026

Copy link
Copy Markdown
Owner Author

Verification of PR #829 at head 602d3fb0de0bb52e65101b4c4960bd7377c65770

Rebased onto main 36b90d14 (merge-base). The PR head was DIRTY against main: main's capability-profile gate (#826/#836/#845) and this PR both added a parameter to load_skill_context. Resolved by keeping both (profile= is passed by the server and kept out of the conformance capture args; catalogues= from this PR).

Fixes made during this finish pass

Commit What Found by
c2ff77c6 Full-profile tools/list budget 12,100 to 12,200. Rebased, the full list measured 12,161: main's external-skill tools left 5 tokens of headroom and catalogues= adds 66. Core budget unchanged (9,261 of 9,400). the context-budget audit after the rebase
602d3fb0 Router fallback: on an error from the security bundle, call sumo_qa_security_testing. Wording test on haiku (router SKILL.md as system prompt, a real oversize error envelope): without the clause 0 of 5 fell back (all 5 retried with include_body=False plus load_techniques, so the skill body never arrived); with it 4 of 5 called the skill tool, and the normal handoff still made the bundle call in 5 of 5. Compressed to fit the 3,510-token router budget (now 3,510). per-file review, medium

Review

  • Per-file sumo-qa-reviewing-before-merge over every changed file's full post-change content vs origin/main...HEAD (generated tests/fixtures/mcp_tools_list_snapshot.json skipped: its regen script leaves the tree clean). Verdict SAFE, no material findings on the final head. src/sumo_qa/conformance.py, server.py, skill_manifest.py, scripts/audit_context_budget.py, scripts/live_first_hop.py, pyproject.toml, skills/sumo-qa-security-testing/SKILL.md, the five docs, the five test modules: SAFE, low findings only. skills/sumo-qa-deciding-approach/SKILL.md: one medium (no fallback when the entry bundle errors), fixed in 602d3fb0, re-reviewed in full: SAFE, lows only.
  • /code-review high, round 1 on the rebase resolution and budget (c2ff77c6): the profile gate holds for bundles (a core-profile bundle for a gated skill returns only the capability error); one low finding. Round 2 on c2ff77c6..602d3fb0: wording-only findings, none blocking; stop rule applied. Open low notes, not fixed here:
    • conformance scores a gated skill's own tool returning "capability unavailable" as entry, while the same refusal through a bundle is not entry. No scenario hits it today.
    • the router fallback line sits next to "never both", and the oversize envelope's own hint suggests retrying with include_body=False; measured at 1 of 5 haiku reps.
    • the router SKILL.md is at exactly its 3,510-token budget.
  • Open review threads: 0.

Acceptance criteria (#802), checked against the branch

AC Status Evidence
Per-family measurement decides wiring; PR states each family met comment 5970662857 table; PR body names each family
Bundle accepts techniques and principles, each part byte-identical met _CATALOGUE_LOADERS in skill_manifest.py; parity tests in tests/test_skill_context_bundle.py; ledger rows 1-2
Each listed skill loads its context in one call after routing met for security-testing; deferred for the other six families ledger row 4; the measurement showed no saving for the others; #802 stays open (PR is Refs)
Audit reports per-loader vs bundled call counts and fails its budgets met scripts/audit_context_budget.py security workflow; tests/test_audit_context_budget.py; ledger row 6
Real before/after session per wired family met ledger row 9
Promptfoo evals show no material regression met ledger row 10

Behaviour ledger (4.7), observed on the real product surface

# Expected behaviour (from the issue) Real-surface call + input Observed output Met
1 Bundle mode accepts catalogues= techniques and principles (AC2) branch wheel c2ff77c (clean venv), headless haiku via MCP, run B: load_skill_context(skill_name="sumo-qa-security-testing", mode="bundle", include_body=false, catalogues="techniques"), then catalogues="principles", then catalogues="classifications,approaches" All three returned a catalogues object with the named parts (results 6,327 / 3,664 / 7,266 chars); agent: "1. No error ... 7. No error" yes
2 Each catalogues= part is byte-identical to its single loader (AC2) run B: each bundle followed by sumo_qa_load_<name>(); served texts compared from the stream-json tool_results catalogues[techniques] len=5926 sha=1fc37ec98f3a = load_techniques; principles len=3317 sha=b158d13d9f08; classifications len=3353 sha=4b39f2834faf; approaches len=3468 sha=343f7bf4b652; identical=True for all 4 yes
3 An unknown catalogue name returns an error envelope listing valid names (PR scope) run B call 8: load_skill_context(..., mode="bundle", catalogues="techniques,widgets") {"error": "Unknown catalogue(s) ['widgets'].", "available_catalogues": ["approaches","classifications","principles","techniques"]}; agent: "8. Error: "Unknown catalogue(s) ['widgets']." Available catalogues: approaches, classifications, principles, techniques" yes
4 A security-testing request routes through the router to ONE bundle call carrying body + security standards/rules + techniques, and the answer uses them (AC3, wired family) branch wheel 602d3fb (clean venv), headless haiku via MCP, runs A1, A2, A4, prompt "I need to security test the password reset endpoint in our Flask app: POST /password-reset ... What security tests should I write for it?" All 3: using_sumo_qa -> sumo_qa_deciding_approach -> sumo_qa_load_skill_context {skill_name: sumo-qa-security-testing, mode: bundle, classification: security_change, catalogues: techniques}; no skill tool, no separate loaders. Bundle keys: body, modules, classifications, standards, rules (security_change: must_consider: - Token lifecycle (issue, refresh, rotate, revoke) - Replay protection ...), catalogues; 17,910 chars. Answers: A1 token lifecycle, enumeration, rate limit, expiry, replay (rules; no technique named); A2 boundary value, state transition, decision table, token lifecycle, replay, residual risk; A4 boundary value, state transition, decision table, equivalence, token lifecycle, residual risk. A 4th run (A3) invented tool names (mcp__sumo_qa__using_sumo_qa: "No such tool available"), never read the router and entered via the skill tool; not counted yes
5 Security-testing entered without the bundle (Skill tool / handoff) still loads standards, rules, techniques via single loaders (fallback, step 2) branch wheel 602d3fb (clean venv), headless haiku via MCP, run D2: "call using_sumo_qa, then sumo_qa_security_testing ... Do NOT call sumo_qa_deciding_approach or sumo_qa_load_skill_context" + the password-reset request using_sumo_qa -> sumo_qa_security_testing -> sumo_qa_load_standards {classification: security_change} -> sumo_qa_load_rules {classification: security_change} -> sumo_qa_load_techniques; answer: token lifecycle, enumeration, rate limit, expiry, replay, residual risk yes
6 Audit reports per-loader vs bundled call counts for each wired workflow and fails its configured budgets (AC4) worktree at c2ff77c: scripts/audit_context_budget.py; then --config copies with (a) security bundle budget 4000, (b) handoff = "false", (c) loaders = " , " Real: workflow security testing (per-loader) 54217 13555 - 8 78101; bundle security testing 17910 4478 4600; workflow security testing (bundled) 55212 13803 - 5 43331; context budget: OK exit 0. (a) FAIL bundle security testing: ~4478 est. tokens > budget 4000 / context budget: FAILED exit 1. (b) config error: context-budget workflow[3] handoff must be true or false exit 2. (c) config error: context-budget workflow[3] loaders must name at least one loader exit 2 yes
7 Conformance scores a successful body-carrying bundle as entry, an errored bundle as not entered (PR scope) branch wheel's transcript_from_debug_dir + validate_transcript, scenario expected_entry_skill=sumo_qa_security_testing, on the real SUMO_QA_DEBUG_DIR captures of runs A1/A2/A4 and of main's A1; and the A1 router captures followed by run B's real error bundle capture (include_body: true, catalogues: "techniques,widgets", output "error": true) cap-A1-pr, cap-A2-pr, cap-A4-pr: [('using_sumo_qa', None), ('sumo_qa_deciding_approach', None), ('sumo_qa_load_skill_context', False)] passed: True []; cap-A1-main (skill tool): passed: True []; router + errored bundle: [..., ('sumo_qa_load_skill_context', True)] passed: False [wrong_skill_routing: "expected entry skill 'sumo_qa_security_testing' was never invoked", first_hop_violation: ...] yes
8 Per-family measurement decides wiring; result stated per family (AC1) gh api repos/sumithr/sumo-qa/issues/comments/5970662857 (compare-mcp-versions --review-mode, haiku, one run per family) + PR body security 330,484/8 turns -> 261,127/4 "21% fewer tokens, equivalent answer: wired"; planning "cheaper, but not from the bundle: not wired"; test-writing "22% more tokens: not wired"; answering "17% more tokens: not wired"; strategising "255% more tokens ... not wired". PR body: "Only the security family is wired, because it is the only family where a real-session measurement showed the bundle saving tokens." yes
9 Real before/after session per wired family shows equal or fewer turns and tokens (AC5) #802 comment 5970662857 (compare-mcp-versions, haiku, security) + this session's A runs, branch 602d3fb wheel vs origin/main 36b90d1 wheel, same agent and prompt Harness: 330,484 tokens / 8 turns -> 261,127 / 4. This session: branch A1/A2/A4 4/4/4 turns, 194,335 / 256,329 / 256,703 tokens; main A1/A2 7/6 turns, 323,176 / 324,495 tokens (main path: skill tool, then load_standards, load_rules/load_techniques). Fewer turns and fewer tokens in every pairing yes
10 Promptfoo evals for each changed skill show no material regression (AC6) Claude-pair npm run eval -- <config> (candidate haiku, judge claude-opus-5-5), single pass, own PROMPTFOO_CONFIG_DIR each; see evals slot skill-deciding-approach 5/5 on 602d3fb; skill-deciding-approach.ab full-skill leg 9/9 (controls A1 1/9, A0 0/9, failing as designed); skill-security-testing 5/5 on c2ff77c (its inputs are unchanged at 602d3fb) yes
11 Non-wired families (preparing-for-work, creating-test-plan, strategising, answering, tdd, strengthening) load context in one call (AC3, rest) branch router SKILL.md catalogue list; existing-flow runs C (see slot) Not wired by design: the router still routes these to their skill tools, which load their own catalogues. The #802 measurement showed no saving for these families. PR is Refs #802, issue stays open for them. DEFERRED (user sign-off recorded by the earlier /finish-pr 829 session; #802 stays open)

Supporting slots

Slot Observed Met
real_repo Every agent run used cwd /Users/SumithRamsookbhai/Desktop/repos/apo/sumo-qa-pr-829, the real sumo-qa worktree at the rebased local head, full history. The audit ran in the same worktree. The conformance captures are the real SUMO_QA_DEBUG_DIR output of those runs. yes
real_surface Branch wheel sumo_qa-0.75.0-py3-none-any.whl built with uv build --wheel from git archive 602d3fb0 (and from c2ff77c for run B), installed into a clean venv (sumo_qa.__file__ = .../scratchpad/v/venv-pr/lib/python3.14/site-packages/sumo_qa/__init__.py), served via python -m sumo_qa with a temp HOME. Each run: ENABLE_TOOL_SEARCH=false claude -p "<prompt>" --model haiku --strict-mcp-config --mcp-config <cfg> --allowedTools mcp__sumo-qa --disallowedTools Bash Write Edit NotebookEdit Skill Agent --disable-slash-commands --output-format stream-json --verbose; all runs exit 0. yes
existing_flow Same agent and prompt ("I'm adding a discount calculation function to our pricing module ... How should I test it?"), branch 602d3fb wheel vs origin/main 36b90d1 wheel. Served outputs diffed (C1 pair): using_sumo_qa, load_classifications, load_approaches, implementing_with_tdd identical; sumo_qa_deciding_approach 21 diff lines, only the PR's intended edits (step 2 wording, step 8 "(security testing: via its bundle)", routing-table row, catalogue-responsibilities handoff bullet with the error fallback, the shortened principles line and red-flag rows, the creating-test-plan line). Routing outcomes: main 4/4 entered a skill (implementing_with_tdd x4); branch 5/6 entered a skill (implementing_with_tdd x3, answering_testing_question x2), 1 answered directly after the router without entering a skill (C2 at 602d3fb). The earlier session saw 4/4 on both sides, so across sessions branch 9/10 vs main 8/8: within haiku noise, not identical. yes (one non-entry noted)
evals eval-reuse-check.py first, against every stored db: all three configs RERUN (the rebase brought main's judge config and changed standards/rules files). Ran each once on the Claude pair with its own PROMPTFOO_CONFIG_DIR. skill-security-testing on c2ff77c: 5 passed (100%), exit 0 (eval-E8i-2026-10-05T10:26:53). skill-deciding-approach first run on c2ff77c 4/5 (case "executable runner package under tests/" chose tdd-scaffold, not verify-existing); stopped the in-flight .ab run when the router fix changed its input; on 602d3fb: 5 passed (100%), exit 0, checker REUSABLE: eval-Vag-2026-10-05T10:38:33 ... 5/5 passed, inputs identical to HEAD. That one case x3 on branch 602d3fb 3/3, on main 36b90d1 2/3: candidate variance, present on main. skill-deciding-approach.ab on 602d3fb: 10 passed (37.04%), by leg B - full skill (current) 9/9, A1 - catalogues only 1/9, A0 - no skill 0/9 (controls fail as designed). The checker still says RERUN on the fresh .ab and security-testing runs for structural reasons (the .ab controls omit skill_content; security-testing's classification-filtered rules/standards vars). yes

Suite, CI and mutation

  • Local suite (pre-push hook on 602d3fb0): pytest (pre-push)...Passed, 6289 passed, 8 skipped, 1 xfailed, Required test coverage of 100% reached. Total coverage: 100.00%; mutmut (pre-push, scoped ...)...Passed.
  • CI: 31 of 31 checks pass on 602d3fb0 (pytest matrix ubuntu 3.10-3.14, macOS and Windows 3.10/3.14, ruff, mypy, drift-and-schemas, context token budget, pip/uvx installs on 3 OSes, plugin-dir handshake, CodeQL, pip-audit, shellcheck, markdown links, no em-dashes).
  • Mutation gate (Linux mutation.yml dispatch on 602d3fb0, run 37299520097): All modules: kill counts >= baseline and 0 survivors. Strict gate passed.

mergeStateStatus BEHIND after main gained #840, #841, #846, #850, #851 (action and ruff bumps, release 0.75.1); git merge-tree against main is clean, so it squash-merges directly.

@sumithr
sumithr merged commit e91f188 into main Oct 5, 2026
32 checks passed
@sumithr
sumithr deleted the feat/issue-802-bundle-routed-skills branch October 5, 2026 12:27
sumithr added a commit that referenced this pull request Oct 5, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.76.0](v0.75.1...v0.76.0)
(2026-10-05)


### Features

* **context:** bundle whole catalogues and enter security-testing
through one bundled call
([#829](#829))
([e91f188](e91f188))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: release-please[bot] <release-please[bot]@users.noreply.github.com>
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