Skip to content

[Task]: Progressive skill loading PR1 — skill manifests + section/module index + partial skill-context loader #285

Closed

Description

@sumithr

Child of #137 (epic: progressive skill/context loading). This is the First PR Slice — the minimum useful path that gives measurable value without changing the existing host activation path.

Depends on: none (foundation slice — ready).

Problem

Every sumo-qa skill tool returns its full SKILL.md body (~136k chars / ~34k approx tokens across 14 skills). Hosts cannot retrieve just the routing summary, one section, or one module — so session-cumulative token cost is high. There is no manifest/index describing each skill's sections, modules, or token weights.

Expected outcome

A read-only, deterministic, local-only pair of tools lets a host load only the slice of skill context it needs, while the existing zero-argument skill tools keep returning full bodies unchanged.

Scope

  • src/sumo_qa/skill_prompts.py (or a new sibling module) — manifest/index generation from skills/*/SKILL.md headings and skills/*/modules/*.md filenames; no LLM extraction.
  • New tools:
    • sumo_qa_list_skill_manifests() — compact metadata for all bundled skills (name, tool_name, description, content_hash, estimated_tokens_full, sections[], modules[]).
    • sumo_qa_load_skill_context(skill_name, mode, section=None, module=None) with mode = "manifest" | "section" | "module" | "full".
  • Stable section ids = slugs from markdown headings; duplicate headings get deterministic suffixes (red-flags, red-flags-2). Module ids = slugs from modules/*.md filenames. Reject path traversal and unknown skill/section/module with actionable error envelopes.
  • docs/TOOLS.md note that the new loader exists (full detail/teaching deferred to PR2).

Acceptance criteria

  • Existing zero-argument skill tools remain unchanged and still return full SKILL.md bodies.
  • First PR adds only sumo_qa_list_skill_manifests and sumo_qa_load_skill_context (or an equivalent minimal pair); larger levers stay follow-ups.
  • A manifest/section/module index exists for every bundled skill (all headings exposed even when canonical heading names differ).
  • required=true is set for frontmatter, Iron Law, HARD-GATE, Checklist, Flow, Red Flags when present.
  • mode="manifest" returns routing summary + section list + module list; mode="section" returns one section; mode="module" returns one module; mode="full" returns byte-for-byte the existing skill tool body.
  • Error envelopes for invalid/missing skill/section/module/mode include the valid choices.
  • New tools are read-only, deterministic, local-only — no MCP resources, catalogue compacting, graph/embedding/cache behavior in this PR.
  • Partial loading preserves Iron Law / HARD-GATE availability.
  • tests/fixtures/mcp_tools_list_snapshot.json regenerated with a reviewable rationale for the two new tools.

Test plan

  • Unit tests: markdown section indexing + stable section ids; duplicate headings; missing/malformed frontmatter; empty sections; unknown skill_name/section/mode.
  • Unit tests: module indexing/loading, missing module reference, path-traversal rejection.
  • Unit tests: manifest/section/module/full loader behavior; mode="full" byte-equivalence to existing tool.
  • pytest tests/test_skill_conformance.py tests/test_tools_list_contract.py tests/test_token_weight_regression.py
  • Run with Node 24 + isolated npm cache if any promptfoo eval is touched (none expected in this PR).

Context

Epic #137 "First PR Slice" + Lever 1 + Lever 2 (loader portion) + "Lazy skill modules — folded from #279". Boundaries: keep host-neutral (#82); honor #89/#172 token budgets. Do NOT add Graphify/GraphRAG/Graphiti/vector store/embeddings. Module-split refactor of sumo-qa-reviewing-before-merge itself is tracked separately (its eval-preservation acceptance lives in the epic); this slice delivers the loader + index mechanism the module pattern depends on.

Roadmap fields: Status: Ready; Priority: P1; Size: M; Depends on: none.

Activity

  1. added
    enhancement
    on Jun 1, 2026
  2. sumithr commented on Jun 1, 2026

    @sumithr
    OwnerAuthor

    Acceptance-criteria verification (PR #292, branch feat/issue-285-progressive-skill-loading-pr1)

    All 9 ACs verified against the branch (not the PR self-description):

    AC Evidence
    Existing zero-arg skill tools unchanged, still return full bodies skill_prompts.py untouched; test_skill_manifest.py::test_full_mode_is_byte_for_byte_equal_to_skill_tool_body
    First PR adds only the two tools snapshot diff = sumo_qa_list_skill_manifests + sumo_qa_load_skill_context only
    Manifest/section/module index for every bundled skill list_skill_manifests() over all skills; test_every_bundled_skill_exposes_a_required_iron_law_and_red_flags
    required=true for frontmatter/Iron Law/HARD-GATE/Checklist/Flow/Red Flags test_required_flag_matches_named_structural_sections
    manifest/section/module/full modes; full byte-for-byte full-mode byte-equivalence test + per-mode tests
    Error envelopes for invalid/missing skill/section/module/mode test_load_unknown_* + test_load_missing_skill_name_returns_required_envelope + test_load_missing_mode_returns_required_envelope (added after codex P2)
    Read-only/deterministic/local-only; no resources/compacting/graph/cache _read_only_local annotation; module does pure markdown + sha256, no I/O beyond reading SKILL.md
    Partial loading preserves Iron Law / HARD-GATE availability those sections are indexed + retrievable by id
    Snapshot regenerated with rationale tests/fixtures/mcp_tools_list_snapshot.json regenerated; test_tools_list_contract green

    Verification evidence: full CI matrix green (Linux/macOS/Windows × py3.10–3.14, ruff, mypy, CodeQL, plugin-install); local full suite 1487 passed, 1 xfailed, 100.00% coverage; sumo-qa review SAFE (5 named risks covered); codex P2 (missing-arg envelope) fixed in 6685c9b.

  3. sumithr commented on Jun 1, 2026

    @sumithr
    OwnerAuthor

    Behavioral verification (finish-pr step 4.7 — feature executed, not just tested)

    Ran the two new tools through the real built MCP server (build_mcp_server()) against the bundled skills on the branch — observed output, not a suite inference:

    • Host surface: both sumo_qa_list_skill_manifests and sumo_qa_load_skill_context are advertised via the server's list_tools() — a host can actually reach them.
    • list_skill_manifests() → metadata for all 14 bundled skills (skill_name, tool_name, sha256 content_hash, estimated_tokens_full, section + module indexes).
    • mode="full" for sumo-qa-reviewing-before-merge is byte-for-byte equal to the existing zero-arg skill tool's body (backward-compat intent, observed live).
    • Reduce session-cumulative token cost with progressive skill/context loading #137 goal (token reduction), measured on the heaviest skill sumo-qa-reviewing-before-merge (~7150 approx tok full):
      • manifest ≈ 595 tok (8% of full)
      • one section (The Iron Law) ≈ 49 tok, content verbatim from SKILL.md
      • manifest + one section ≈ 644 tok → 91% fewer tokens than loading the full body (AC asked for ≥50% below for the heaviest skills; observed 91%).
    • Error envelopes never raise — observed for: missing skill_name, missing mode, unknown skill, unknown section, path-traversal (../../etc/passwd rejected), and mode="module" with no modules. Each returns {"error": ..., "available_*": [...]}.

    The feature does what #285/#137 intended: a host can load just the routing summary or one section at a fraction of the full-body cost, while the full body stays byte-identical to today's tool.

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

    enhancementtooling

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions