From b736babe435f463ffbb2cffbf3fb4099a9249d20 Mon Sep 17 00:00:00 2001 From: sumithr <38540179+sumithr@users.noreply.github.com> Date: Mon, 20 Jul 2026 11:19:33 +0200 Subject: [PATCH 1/2] revert: remove the output-profile feature (#215/#471) as a negative result Reverts 577527e. SUMO_QA_OUTPUT_PROFILE (the concise/strict serve-time overlays, plus the lean profile explored under #528) is removed. Measurement under the #528 investigation showed a serve-time prompt overlay cannot reliably reduce the reply a host emits: a strong model, given the tightened contract and grounded input, still produced a full structured QA plan, and a weak model ignored the brevity instruction amid ~10x run-to-run variance. The model's task-completion drive overrides a prepended "be brief", so the knob did not do its job and is dead code. - Reverts the profile overlay system in skill_prompts.py, keeping the #476 conformance capture-wrapping and the #393 over-cap pointer (both unrelated). - Removes the profile docs from CONFIGURATION, TOOLS, SKILLS, ARCHITECTURE. - Rewrites the epic #211 "verbosity fatigue" control row in RELIABILITY-HARDENING.md to record the negative result honestly. Regression: ruff + mypy clean; 3211 passed, 100% coverage. --- docs/ARCHITECTURE.md | 2 +- docs/CONFIGURATION.md | 42 ------ docs/RELIABILITY-HARDENING.md | 48 +++--- docs/SKILLS.md | 6 +- docs/TOOLS.md | 4 +- src/sumo_qa/server.py | 9 +- src/sumo_qa/skill_manifest.py | 8 +- src/sumo_qa/skill_prompts.py | 136 +++-------------- src/sumo_qa/skill_resources.py | 5 +- tests/test_skill_prompts.py | 260 +-------------------------------- 10 files changed, 56 insertions(+), 464 deletions(-) diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index eddaa510..6e6faf7d 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -64,7 +64,7 @@ the skill. ## 2. MCP tools (Python): atomic knowledge providers The tools are all thin. Skill tools (one per SKILL.md) and knowledge loaders (`sumo_qa_load_*`) -return markdown catalogues as text. Each served skill body is optionally reshaped by an output profile (`SUMO_QA_OUTPUT_PROFILE=concise|default|strict`, #215): a small serve-time overlay tunes verbosity/strictness without editing any SKILL.md, with `default` serving the body byte-for-byte and the mandatory gates (Iron Law, HARD-GATE, evidence, confirmation-before-write) never downgraded. A read-only progressive-loading pair (`sumo_qa_list_skill_manifests`, `sumo_qa_load_skill_context`) indexes each SKILL.md's sections/modules and serves a single slice (manifest / section / module / full) as a JSON string so a host can load just the routing summary or one section rather than the whole body; `mode="full"` returns the same bytes as the skill tool under the default output profile (under `concise`/`strict` the skill tool prepends the profile overlay while this loader always serves the canonical body, keeping every `content_hash` stable across profiles), except that a body over the host's per-response token cap is served through both paths as a compact `oversize` pointer to the manifest/section/module slices instead of the over-cap body the host would refuse (#393). `sumo_qa_list_skill_manifests` is a *compact* all-skill routing aid by default (`detail="compact"`: per-skill metadata only, no section/module arrays); the full all-skill index is an explicit `detail="full_index"` opt-in, while the per-skill manifest/section/module/full slices of `sumo_qa_load_skill_context` are the progressive-loading ladder a host climbs once it has chosen a skill. Each partial slice carries a `content_hash` (sha256 of the returned text) and `estimated_tokens`; a caller can pass `known_hash` to get a derived `changed` flag (body omitted when unchanged). This change-detection is stateless; there is no server-side session cache, because MCP session identity is not reliable across the supported hosts, so re-hashing the live slice per call is preferred over a cache keyed on an unstable identity. The same index is additionally exposed as additive MCP resources/resource-templates (`sumoqa://skills`, `sumoqa://skills/{name}/manifest|sections/{id}|modules/{id}|full`) whose bodies are byte-for-byte the loader output, for hosts that surface resources; the model-callable tools stay the canonical, unchanged path. A capabilities-discovery tool (`sumo_qa_capabilities`) returns a compact, typed map of the core QA workflows. Repo-map tools build and consume the QA-native `.sumo-qa/repo-map.json` artifact, each returning a compact typed summary rather than the full map. A risk-to-test ledger formatter (`sumo_qa_format_risk_ledger`) validates host-supplied risk rows and renders the structured verdict appendix: no inference, file/format plumbing only. A context-bundle formatter (`sumo_qa_format_context_bundle`) validates a host-neutral issue/PR context bundle and renders its brief plus its freshness/conflict signals (an optional review/planning *input*, never a network call or GitHub dependency). A QA-readiness-scorecard composer (`sumo_qa_format_qa_scorecard`) reuses those two artifacts plus optional coverage/mutation signals to *derive* a readiness recommendation (ready / ready_with_accepted_residuals / blocked / insufficient_evidence). It is an evidence summary, not a predictive quality score; it invents no numeric score and refuses a ready state while a risk is an uncovered blocker or evidence is stale. A QA-artifact exporter (`sumo_qa_export_test_cases`) deterministically renders host-supplied, already-structured test cases into versioned JSON, a markdown table, or (for flat outlines) CSV. Markdown stays the default human-facing output, exports are side-effect free, and there is no vendor lock-in or new mandatory dependency. A local QA-report composer (`sumo_qa_generate_qa_report`, CLI mirror `sumo-qa report`) projects the persisted `.sumo-qa` artifacts into one self-contained static HTML page with honest not-available states and a readiness verdict derived by the #151 `QaScorecard` engine (the single source of truth, so the report and the scorecard can never disagree): no inference, no network, the HTML body only lands on disk via `write_to`. Test-data tools read/write the local +return markdown catalogues as text. A read-only progressive-loading pair (`sumo_qa_list_skill_manifests`, `sumo_qa_load_skill_context`) indexes each SKILL.md's sections/modules and serves a single slice (manifest / section / module / full) as a JSON string so a host can load just the routing summary or one section rather than the whole body; `mode="full"` returns the same bytes as the skill tool, except that a body over the host's per-response token cap is served through both paths as a compact `oversize` pointer to the manifest/section/module slices instead of the over-cap body the host would refuse (#393). `sumo_qa_list_skill_manifests` is a *compact* all-skill routing aid by default (`detail="compact"`: per-skill metadata only, no section/module arrays); the full all-skill index is an explicit `detail="full_index"` opt-in, while the per-skill manifest/section/module/full slices of `sumo_qa_load_skill_context` are the progressive-loading ladder a host climbs once it has chosen a skill. Each partial slice carries a `content_hash` (sha256 of the returned text) and `estimated_tokens`; a caller can pass `known_hash` to get a derived `changed` flag (body omitted when unchanged). This change-detection is stateless; there is no server-side session cache, because MCP session identity is not reliable across the supported hosts, so re-hashing the live slice per call is preferred over a cache keyed on an unstable identity. The same index is additionally exposed as additive MCP resources/resource-templates (`sumoqa://skills`, `sumoqa://skills/{name}/manifest|sections/{id}|modules/{id}|full`) whose bodies are byte-for-byte the loader output, for hosts that surface resources; the model-callable tools stay the canonical, unchanged path. A capabilities-discovery tool (`sumo_qa_capabilities`) returns a compact, typed map of the core QA workflows. Repo-map tools build and consume the QA-native `.sumo-qa/repo-map.json` artifact, each returning a compact typed summary rather than the full map. A risk-to-test ledger formatter (`sumo_qa_format_risk_ledger`) validates host-supplied risk rows and renders the structured verdict appendix: no inference, file/format plumbing only. A context-bundle formatter (`sumo_qa_format_context_bundle`) validates a host-neutral issue/PR context bundle and renders its brief plus its freshness/conflict signals (an optional review/planning *input*, never a network call or GitHub dependency). A QA-readiness-scorecard composer (`sumo_qa_format_qa_scorecard`) reuses those two artifacts plus optional coverage/mutation signals to *derive* a readiness recommendation (ready / ready_with_accepted_residuals / blocked / insufficient_evidence). It is an evidence summary, not a predictive quality score; it invents no numeric score and refuses a ready state while a risk is an uncovered blocker or evidence is stale. A QA-artifact exporter (`sumo_qa_export_test_cases`) deterministically renders host-supplied, already-structured test cases into versioned JSON, a markdown table, or (for flat outlines) CSV. Markdown stays the default human-facing output, exports are side-effect free, and there is no vendor lock-in or new mandatory dependency. A local QA-report composer (`sumo_qa_generate_qa_report`, CLI mirror `sumo-qa report`) projects the persisted `.sumo-qa` artifacts into one self-contained static HTML page with honest not-available states and a readiness verdict derived by the #151 `QaScorecard` engine (the single source of truth, so the report and the scorecard can never disagree): no inference, no network, the HTML body only lands on disk via `write_to`. Test-data tools read/write the local known-good catalogue under `knowledge/test_data/`. An ingestion tool materialises runtime knowledge packs into a user-writable location. External-skill lifecycle tools search, install, locate, and load external skills through the Skills CLI while preserving the skill-level confirmation gate. The search tool returns ANSI-stripped CLI output verbatim (no structured parsing) so Skills CLI format drift doesn't break the flow. See [TOOLS.md](TOOLS.md) for the full list. diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md index ee79e3b1..3531d4e8 100644 --- a/docs/CONFIGURATION.md +++ b/docs/CONFIGURATION.md @@ -9,7 +9,6 @@ All optional. Defaults work out of the box after `pip install sumo-qa && sumo-qa | `QA_TEST_DATA_PATH` | `knowledge/test_data` (cwd) | Override the known-good test data catalogue. **No samples ship in the wheel**, the catalogue is empty on a fresh install; populate it per your team's domains. | | `QA_KNOWLEDGE_PATH` | bundled `_data/knowledge` / repo `knowledge` | Override the canonical knowledge catalogues (classifications, approaches, principles, techniques) | | `SUMO_QA_DEBUG_DIR` | unset | Directory to capture per-tool-call args + output as JSON for debugging / grading | -| `SUMO_QA_OUTPUT_PROFILE` | `default` | Output verbosity/strictness profile for served skill bodies: `concise`, `default`, or `strict` (see [Output verbosity and strictness profiles](#output-verbosity-and-strictness-profiles)). An unrecognised value falls back to `default`. | These env vars are the lowest-level override and always win. For a no-clone way to add custom content, see [Adding custom knowledge without cloning the @@ -17,47 +16,6 @@ repo](#adding-custom-knowledge-without-cloning-the-repo) below, it inserts ingested project/global packs as middle tiers between the env vars and the bundled defaults. -## Output verbosity and strictness profiles - -`SUMO_QA_OUTPUT_PROFILE` tunes how much ceremony wraps the skill guidance -sumo-qa serves, so a small docs-only or test-only edit does not feel like a -full QA audit while security, API, migration, and release-gate work still gets -strict handling. It is a serve-time overlay on the single skill-serving path, -so no skill file is edited and the canonical `SKILL.md` content stays readable -and host-neutral. - -| Value | Effect | -|---|---| -| `concise` | Shortest useful answer: one focused risk/test summary, findings over framing, no formal section headers or evidence tables unless the skill marks them mandatory. | -| `default` | Current behaviour. The skill body is served byte-for-byte, unchanged. | -| `strict` | Full ceremony: each gate stated explicitly, evidence as a table, every named risk mapped to its test, and an explicit residual-risk section. | - -An unrecognised value (a typo, an unknown name) falls back predictably to -`default` rather than failing, so a misconfigured host can never break serving -or silently drop a gate. - -**Never optional, at any profile.** A profile tunes how much prose wraps the -work, never whether the mandatory gates hold. Whatever the profile, the served -overlay restates that the skill's Iron Law and any HARD-GATE, evidence for -every claim, explicit user confirmation before writing files or installing -anything, and every mandatory test or safety gate the skill names are always -kept. Concise mode shortens low-risk output; it does not drop a gate on -high-risk work. Strict mode adds structure to the skill body only; it does not -touch the `sumo_qa_load_*` catalogue payloads, so it cannot bloat them. - -```json -{ - "mcpServers": { - "sumo-qa": { - "command": "sumo-qa", - "env": { - "SUMO_QA_OUTPUT_PROFILE": "concise" - } - } - } -} -``` - ## Example: custom team standards ```json diff --git a/docs/RELIABILITY-HARDENING.md b/docs/RELIABILITY-HARDENING.md index 7bc09997..00d26667 100644 --- a/docs/RELIABILITY-HARDENING.md +++ b/docs/RELIABILITY-HARDENING.md @@ -41,30 +41,30 @@ INTENTIONALLY BOUNDED (residual named and accepted), never open or unaddressed. ### 2. Verbosity fatigue -- **Classification:** intentionally bounded (mechanism merged and pinned; host compliance - is behavioral). -- **Control (merged):** `SUMO_QA_OUTPUT_PROFILE=concise|default|strict` serve-time - overlays on the single skill-serving path. Every overlay restates the never-optional - floor (Iron Law, HARD-GATE, evidence for claims, confirmation before writes/installs). - Unrecognised values fall back to `default`; the overlay rides the oversize pointer only - when the combination itself fits the token cap. -- **Owner / delivery:** issue #215, PR #471 (merged 2026-07-13). -- **Evidence:** `src/sumo_qa/skill_prompts.py`; the profile suite in - `tests/test_skill_prompts.py` (14 tests: byte-for-byte default through the real - registration path, overlay prepending, env-var call-time selection, invalid fallback, - mandatory-gate preservation, token-cap degradation); documentation contract in - `docs/CONFIGURATION.md`, `docs/TOOLS.md`, `docs/SKILLS.md`, and `docs/ARCHITECTURE.md`. - Live merge-gate proof: sha256-verified byte identity of default serving and the router - against the pre-change code, overlay heads with the gate language intact; see the batch - proof comment on PR #471. -- **Default / compatibility:** `default` serves every body byte-for-byte. The overlay - applies to the skill-tool surface only; `sumo_qa_load_skill_context` and the - `sumoqa://` resources always serve the canonical body so `content_hash` - change-detection stays stable across profiles. -- **Residual limit:** whether a host LLM actually emits shorter output under `concise` - is host-behavioral and cannot be proven by unit tests or disk-reading evals; the issue - author left that acceptance box unchecked by design. The discharge path is a live - A/B comparison across MCP builds. +- **Classification:** intentionally bounded, no serve-time control. A serve-time + output-profile mechanism was tried and reverted (a documented negative result). +- **Control:** none shipped. `SUMO_QA_OUTPUT_PROFILE` (the `concise`/`strict` serve-time + overlays, #215/#471) was reverted after the #528 investigation measured that a + serve-time prompt overlay cannot reliably reduce the reply a host emits: a prepended + brevity instruction loses to the model's task-completion drive. A strong model, given + the tightened contract and grounded input, still produced a full structured QA plan; + a weak model ignored the instruction amid large (~10x) run-to-run variance. Rather than + ship a knob that does not do its job, the feature was removed. +- **Owner / delivery:** issue #215, PR #471 (merged 2026-07-13); reverted under the #528 + investigation (this removal reverts commit `577527e`). +- **Evidence:** the removal reverts `577527e` and its documentation; the #528 + investigation records the A/B measurements and the strong-model contrast that showed no + reliable reduction. The skill-serving path returns to serving each `SKILL.md` body + byte-for-byte (the pre-#215 behavior), with the #393 over-cap progressive-loading + pointer unchanged. +- **Default / compatibility:** the removal is behavior-preserving for the common case: + the zero-argument skill tools serve the canonical body (the same bytes `default` + served), and the `sumo_qa_load_skill_context` loader and `sumoqa://` resources are + unchanged. +- **Residual limit:** verbosity is left to the host. If reply length must be controlled, + the effective levers are host-side (the host's own output settings) or fewer, more + structured turns, not a served overlay. The original acceptance box (does the host + actually emit shorter output) has now been answered: not via a serve-time overlay. ### 3. Enforcement uncertainty (unsupported workflow claims) diff --git a/docs/SKILLS.md b/docs/SKILLS.md index 989b5696..292f1b47 100644 --- a/docs/SKILLS.md +++ b/docs/SKILLS.md @@ -4,7 +4,7 @@ The sumo-qa MCP ships a library of skills under [`skills/`](../skills/). Each is `SKILL.md` file the host LLM follows literally: YAML frontmatter, an Iron Law, a checklist, a Process Flow section, a Red Flags table, examples. -Each skill is also exposed as an MCP tool with the same name (e.g. `sumo_qa_deciding_approach`). The tool returns the SKILL.md body verbatim under the default output profile (a non-default `SUMO_QA_OUTPUT_PROFILE` prepends a small overlay, see [Configuration](CONFIGURATION.md#output-verbosity-and-strictness-profiles)), so hosts that don't have a native skill loader (JetBrains AI Assistant, Junie, VS Code Copilot) get the same content. +Each skill is also exposed as an MCP tool with the same name (e.g. `sumo_qa_deciding_approach`). The tool returns the SKILL.md body verbatim, so hosts that don't have a native skill loader (JetBrains AI Assistant, Junie, VS Code Copilot) get the same content. **SKILL.md prose defines host-neutral obligations**, capability contracts like *"maintain an ordered work tracker"* or *"dispatch a fresh delegated worker"*. The same body is exposed to every host through whichever surface that host provides (native slash command, MCP tool, agentic-mode tool selection). Skill bodies and contract docs deliberately avoid naming any one host's tools; see `using-sumo-qa` → *Shared vocabulary* for the canonical capability terms each host adapts, and `tests/test_skill_conformance.py` for the regression guard. @@ -14,7 +14,7 @@ Slash-menu conventions differ per host: - **JetBrains AI Assistant**: `/sumo_qa_deciding_approach` (underscores): comes from the MCP tool. Every MCP entry is slash-invocable. - **JetBrains Junie / VS Code Copilot**: Natural language; the AI picks the tool by description in Agent mode. -All paths invoke the same SKILL.md body. Under a non-default `SUMO_QA_OUTPUT_PROFILE` the MCP skill tool prepends a small output-profile overlay to that body; native skill files and the progressive-loading loader (`sumo_qa_load_skill_context`) always carry the canonical text. +All paths invoke the same SKILL.md body. ## The skills @@ -67,7 +67,7 @@ A skill body can be loaded whole, or in slices, through the partial loader (`sum - **manifest**: compact routing metadata (description, token weights, section/module ids, which sections are `required`). A *navigation aid*, not the instruction. Use it to pick a skill and see its shape. - **section** / **module**: one verbatim slice of the body (e.g. just the Iron Law, or one lazy module). **Canonical**: cite or follow it directly. -- **full**: the entire canonical body, byte-for-byte identical to the zero-argument skill tool under the default output profile (under `concise`/`strict` the skill tool prepends the profile overlay; this loader always serves the canonical bytes). **Canonical**: load it when you are about to *execute* the skill and need the exact procedure wording. If a body would exceed the host's per-response token cap (today only `sumo-qa-reviewing-before-merge`), `mode="full"` and the zero-argument tool both return a compact `oversize` pointer to the manifest/section/module slices instead of the over-cap body the host would refuse (#393), so load that skill progressively. +- **full**: the entire body, byte-for-byte identical to the zero-argument skill tool. **Canonical**: load it when you are about to *execute* the skill and need the exact procedure wording. If a body would exceed the host's per-response token cap (today only `sumo-qa-reviewing-before-merge`), `mode="full"` and the zero-argument tool both return a compact `oversize` pointer to the manifest/section/module slices instead of the over-cap body the host would refuse (#393), so load that skill progressively. **Canonical vs compact.** `section`, `module`, and `full` are verbatim from the file and may be followed as authoritative. The manifest paths are compact summaries for routing only, never treat a manifest description or section list as the procedure. When a workflow is actually running and depends on exact wording (Iron Law, HARD-GATE, the step-by-step checklist), load the full body or the specific section, not the manifest. diff --git a/docs/TOOLS.md b/docs/TOOLS.md index cbb0b46a..6088454a 100644 --- a/docs/TOOLS.md +++ b/docs/TOOLS.md @@ -8,8 +8,6 @@ Each returns the full body of a `skills//SKILL.md` file. The host LLM trea The skill bodies are host-neutral: they declare capability obligations (ordered work tracker, structured user-choice prompt, fresh delegated worker; see `using-sumo-qa` → *Shared vocabulary*) rather than naming any one host's specific tools. Adapters surface the same bodies through host-specific UIs (Claude Code slash commands, JetBrains MCP slash commands, Copilot agentic-mode tool selection, etc.). -**Output profile (#215).** `SUMO_QA_OUTPUT_PROFILE=concise|default|strict` tunes how much ceremony wraps the served body: `concise` prepends a small overlay asking for the shortest useful answer, `strict` asks for full gate language plus an evidence table and a residual-risk section, and `default` (the default, and the fallback for any unrecognised value) serves the body byte-for-byte. The overlay is a bounded serve-time addition on this single path, so no `SKILL.md` is edited and the `sumo_qa_load_*` catalogue payloads are untouched. Whatever the profile, the mandatory gates are never downgraded: the skill's Iron Law and any HARD-GATE, evidence for every claim, confirmation before any write or install, and every required test or safety gate always hold. The overlay applies to the skill-tool serving surface only (it also rides the #393 oversize pointer when it fits the cap): `sumo_qa_load_skill_context` and the `sumoqa://` resources always serve the canonical body byte-for-byte, so `content_hash` change-detection stays stable across profiles. See [Configuration](CONFIGURATION.md#output-verbosity-and-strictness-profiles). - Each skill registers as a tool named after its directory with hyphens turned to underscores (`using-sumo-qa` → `using_sumo_qa`, `sumo-qa-deciding-approach` → `sumo_qa_deciding_approach`). In JetBrains AI Assistant these are slash commands (`/sumo_qa_deciding_approach`). In Claude Code the equivalent slash commands come from the native skill files (`/sumo-qa-deciding-approach`, hyphens); the MCP tools are still callable but only via natural language ("decide the QA approach for this refactor"). VS Code Copilot and Junie pick them by description in Agent / agentic mode. @@ -36,7 +34,7 @@ The four modes form a retrieval ladder. Climb only as far as the work needs: | **Manifest (all skills)** | `sumo_qa_list_skill_manifests(detail="compact")` | No: routing aid | Choosing which skill applies. The default `detail="compact"` returns per-skill metadata for every skill at once, but **not** the `sections[]`/`modules[]` arrays, so it stays cheap (~2,176 approx tokens, guarded under a 2,500 budget). `detail="full_index"` adds each skill's `sections[]`/`modules[]` *index* arrays (ids + token weights, never the bodies) at ~11,219 approx tokens, guarded under a 13,000 ceiling. Once a skill is chosen, fetch its section/module index via `load_skill_context(skill, "manifest")` rather than carrying every skill's index up front. | | **Manifest (one skill)** | `load_skill_context(skill, "manifest")` | No: routing aid | You've chosen a skill and want its section/module map (ids, token weights, which sections are `required`) before pulling any body. | | **Section / Module** | `load_skill_context(skill, "section"/"module", …)` | **Yes**: verbatim slice | You need one part of a skill (its Iron Law, one checklist, one lazy module) and not the rest. The returned text is byte-for-byte from the file. | -| **Full** | `load_skill_context(skill, "full")` or the zero-arg skill tool | **Yes**: verbatim body (or an `oversize` pointer); identical through both paths under the default profile (a non-default profile overlays the skill tool only) | You are about to **execute** the skill. When exact procedure wording matters (Iron Law, HARD-GATE, the operational checklist a workflow follows step-by-step) load the full body. A body over the host's per-response token cap returns an `oversize` pointer to the slices instead (#393); load them progressively. | +| **Full** | `load_skill_context(skill, "full")` or the zero-arg skill tool | **Yes**: verbatim body (or an `oversize` pointer) | You are about to **execute** the skill. When exact procedure wording matters (Iron Law, HARD-GATE, the operational checklist a workflow follows step-by-step) load the full body. A body over the host's per-response token cap returns an `oversize` pointer to the slices instead (#393); load them progressively. | **Canonical means verbatim.** `section`, `module`, and `full` return text copied straight from `SKILL.md` (or a module file); a host may cite or follow them as the authoritative instruction. The two **manifest** paths are *compact navigation aids*: they summarise structure and token weights to help a host route, and are **not** a substitute for the procedure text. Do not treat a manifest description or section list as the instruction to follow; once a skill is actually being executed, load the section(s) or the full body so the model has the exact wording. The same rule governs the knowledge catalogues: a compact summary is for recall, the loaded catalogue text is what you cite. diff --git a/src/sumo_qa/server.py b/src/sumo_qa/server.py index 5cdf8fe2..a3f90229 100644 --- a/src/sumo_qa/server.py +++ b/src/sumo_qa/server.py @@ -1929,9 +1929,7 @@ def sumo_qa_list_skill_manifests(detail: str = "compact") -> str: An unrecognised `detail` returns a JSON error envelope listing the valid values rather than raising. Read-only and local-only: no network, no extraction, no caching. The existing zero-argument skill tools still - return full bodies unchanged under the default output profile; a - non-default `SUMO_QA_OUTPUT_PROFILE` (#215) prepends a small verbosity - overlay to those skill-tool bodies, while this index stays unchanged.""" + return full bodies unchanged.""" return json.dumps(_list_skill_manifests(detail), ensure_ascii=False, indent=2) @mcp.tool(annotations=_read_only_local) @@ -1952,10 +1950,7 @@ def sumo_qa_load_skill_context( - "module" — one module's text (pass `module`, an id from the manifest); - "full" — the entire SKILL.md body, byte-for-byte identical to the - existing zero-argument skill tool for `skill_name` under the default - output profile (under `concise`/`strict` the skill tool prepends the - #215 profile overlay while this loader always serves the canonical - body, keeping `content_hash` stable across profiles); a body over the + existing zero-argument skill tool for `skill_name`; a body over the host's per-response token cap is returned as an `oversize` pointer to the manifest/section/module slices instead of failing (#393). diff --git a/src/sumo_qa/skill_manifest.py b/src/sumo_qa/skill_manifest.py index 6dd28a84..a66b4984 100644 --- a/src/sumo_qa/skill_manifest.py +++ b/src/sumo_qa/skill_manifest.py @@ -413,12 +413,8 @@ def load_skill_context( * ``"section"`` — one section's text (requires ``section``). * ``"module"`` — one module's text (requires ``module``). * ``"full"`` — the entire SKILL.md body, byte-for-byte identical to - the existing zero-argument skill tool for this skill under the default - output profile (under a non-default ``SUMO_QA_OUTPUT_PROFILE`` the skill - tool prepends the #215 profile overlay while this loader always serves - the canonical body, keeping ``content_hash`` stable across profiles). - When that body exceeds the per-response token cap (``token_cap`` > env - var > default), + the existing zero-argument skill tool for this skill. When that body + exceeds the per-response token cap (``token_cap`` > env var > default), an oversize pointer envelope (``oversize=True``, no ``content``) naming the manifest/section/module route is returned instead (#393). diff --git a/src/sumo_qa/skill_prompts.py b/src/sumo_qa/skill_prompts.py index 038af2b0..17d18868 100644 --- a/src/sumo_qa/skill_prompts.py +++ b/src/sumo_qa/skill_prompts.py @@ -57,55 +57,6 @@ DEFAULT_SKILL_RESPONSE_TOKEN_CAP = 12000 _RESPONSE_TOKEN_CAP_ENV = "SUMO_QA_SKILL_RESPONSE_TOKEN_CAP" -# --- Output-profile overlay (#215) --------------------------------------- -# SUMO_QA_OUTPUT_PROFILE tunes how much ceremony wraps a served skill body so -# small, low-risk changes don't feel like a full QA audit while risky work -# still gets strict handling. It is a serve-time overlay on the SINGLE skill- -# serving path (this module), NOT a per-skill rewrite: the canonical SKILL.md -# files stay readable and host-neutral, and `default` serves them byte-for-byte -# (backwards compatible). Only the skill body is touched — the sumo_qa_load_* -# catalogue payloads are untouched, so strict mode cannot bloat them. -DEFAULT_OUTPUT_PROFILE = "default" -_OUTPUT_PROFILE_ENV = "SUMO_QA_OUTPUT_PROFILE" -_VALID_OUTPUT_PROFILES = ("concise", "default", "strict") - -# The non-negotiable floor. Whatever the profile, these obligations are never -# skipped or shortened away — this is the safety guarantee behind the issue's -# non-goal "No profile may allow skipping required tests, evidence, -# confirmations, or safety gates." Every non-default overlay restates it so a -# high-risk workflow keeps its gates even in concise mode. -_NEVER_OPTIONAL = ( - "Whatever the profile, these are never skipped or shortened away: the " - "skill's Iron Law and any HARD-GATE; evidence for every claim (show the " - "command and its output, never assert a pass without proof); explicit user " - "confirmation before writing files, running mutating commands, or " - "installing anything; and every mandatory test or safety gate the skill " - "names. A profile tunes how much prose wraps the work, never whether these " - "hold." -) - -_CONCISE_OVERLAY = ( - "> Output profile: concise. Give the shortest useful answer for this " - "change: one focused risk/test summary, findings over framing, no formal " - "section headers or evidence tables unless the skill marks them mandatory. " - "Drop preamble, restating, and closing pleasantries. " + _NEVER_OPTIONAL + "\n\n---\n\n" -) - -_STRICT_OVERLAY = ( - "> Output profile: strict. Use the skill's full ceremony: state each gate " - "explicitly, present evidence as a table, map every named risk to the test " - "that covers it, and close with an explicit residual-risk section. Prefer " - "completeness over brevity while staying grounded — never pad with generic " - "advice. " + _NEVER_OPTIONAL + "\n\n---\n\n" -) - -_PROFILE_OVERLAYS = { - "concise": _CONCISE_OVERLAY, - "strict": _STRICT_OVERLAY, - # `default` intentionally maps to no overlay (byte-for-byte body). - "default": "", -} - def _approx_tokens(text: str) -> int: """Approximate token count: length / 4, rounded up. Mirrors the estimator @@ -132,30 +83,6 @@ def _response_token_cap(override: int | None = None) -> int: return DEFAULT_SKILL_RESPONSE_TOKEN_CAP -def _resolve_output_profile(override: str | None = None) -> str: - """Resolve the active output profile: explicit override > env var > - documented default. Resolution is case/whitespace-insensitive. An - unrecognised value (typo, unknown profile) falls back predictably to - `default` — mirroring `_response_token_cap`'s bad-env handling — so a - misconfigured host can never break serving or silently drop a gate.""" - raw = override if override is not None else os.environ.get(_OUTPUT_PROFILE_ENV) - if raw is None: - return DEFAULT_OUTPUT_PROFILE - normalized = raw.strip().lower() - if normalized in _VALID_OUTPUT_PROFILES: - return normalized - return DEFAULT_OUTPUT_PROFILE - - -def _profile_overlay(profile: str) -> str: - """Return the serve-time overlay prepended to a skill body for `profile`. - - `default` returns "" (the body is served byte-for-byte). `concise` and - `strict` return a small, bounded directive block that reshapes the host's - output while restating the never-optional gate floor.""" - return _PROFILE_OVERLAYS.get(profile, "") - - def _skills_dir() -> Path: """Return the directory holding SKILL.md files. @@ -184,9 +111,7 @@ def _parse_frontmatter(text: str) -> dict: return parsed or {} -def register_skills_as_prompts( - mcp: Any, token_cap: int | None = None, profile: str | None = None -) -> None: +def register_skills_as_prompts(mcp: Any, token_cap: int | None = None) -> None: """Register every SKILL.md under skills/ as an MCP tool. Name kept as the historic `register_skills_as_prompts` for backwards @@ -195,11 +120,9 @@ def register_skills_as_prompts( Name: directory name with `-` -> `_`. Description: from frontmatter. Body: full file content (including frontmatter), read fresh on each call - so editing the SKILL.md propagates without restart, and reshaped by the - active output profile (#215, resolved from SUMO_QA_OUTPUT_PROFILE). An - over-cap body is served as a progressive-loading pointer instead (#393); - `token_cap` overrides the resolved cap and `profile` overrides the resolved - profile — both are used by tests. + so editing the SKILL.md propagates without restart. An over-cap body is + served as a progressive-loading pointer instead (#393); `token_cap` + overrides the resolved cap and is used by tests. """ skills_dir = _skills_dir() if not skills_dir.is_dir(): @@ -218,7 +141,7 @@ def register_skills_as_prompts( # hosts that render descriptions inline don't show stray newlines. if isinstance(description, str): description = " ".join(description.split()) - _bind_tool(mcp, name, description, skill_path, token_cap=token_cap, profile=profile) + _bind_tool(mcp, name, description, skill_path, token_cap=token_cap) def _oversize_pointer_text(skill_name: str, tokens: int, cap: int) -> str: @@ -243,7 +166,7 @@ def _oversize_pointer_text(skill_name: str, tokens: int, cap: int) -> str: ) -def _make_skill_callable(path: Path, token_cap: int | None = None, profile: str | None = None): +def _make_skill_callable(path: Path, token_cap: int | None = None): """Factory returning a zero-argument function that reads `path` at call time. The factory closes over `path` so each generated function returns its OWN @@ -251,60 +174,37 @@ def _make_skill_callable(path: Path, token_cap: int | None = None, profile: str keeps the function's signature parameter-free, which FastMCP's tool introspection requires. - The active output profile (#215) is resolved FRESH on each call (env var > - documented default), so a host config change takes effect without a rebind — - the same freshness philosophy as reading the SKILL.md each call. For - `concise`/`strict` a small overlay is prepended to the body; `default` leaves - the body byte-for-byte unchanged. `profile` is an explicit override used by - tests (falls through to the env var when None). - - When the composed body would exceed the per-response token cap (#393), the - function returns a compact pointer to the progressive-loading route instead - of the oversized body (which the host refuses and saves to a file); the - profile overlay is preserved on the pointer so the host still knows the - active profile, but ONLY when overlay + pointer itself fits the cap. With a - cap small enough that the overlaid pointer would overflow it, the overlay is - dropped: the pointer is the degraded-mode payload and must never recreate - the over-cap response it exists to prevent. Under-cap `default` skills - return the body byte-for-byte, unchanged. `token_cap` overrides the + When the body would exceed the per-response token cap (#393), the function + returns a compact pointer to the progressive-loading route instead of the + oversized body (which the host refuses and saves to a file). Under-cap + skills return the body byte-for-byte, unchanged. `token_cap` overrides the resolved cap (env var > default) and is used by tests. """ cap = _response_token_cap(token_cap) def _skill_body() -> str: - overlay = _profile_overlay(_resolve_output_profile(profile)) text = path.read_text(encoding="utf-8") - body = overlay + text if overlay else text - tokens = _approx_tokens(body) + tokens = _approx_tokens(text) if tokens > cap: - pointer = _oversize_pointer_text(path.parent.name, tokens, cap) - if overlay and _approx_tokens(overlay + pointer) <= cap: - return overlay + pointer - return pointer - return body + return _oversize_pointer_text(path.parent.name, tokens, cap) + return text return _skill_body def _bind_tool( - mcp: Any, - name: str, - description: str, - path: Path, - token_cap: int | None = None, - profile: str | None = None, + mcp: Any, name: str, description: str, path: Path, token_cap: int | None = None ) -> None: """Bind one SKILL.md as an MCP tool named `name`. The tool returns the - SKILL.md body (reshaped by the active output profile, #215), which the host - LLM follows, or a progressive-loading pointer when the body would exceed the - per-response token cap (#393). + SKILL.md body, which the host LLM follows, or a progressive-loading pointer + when the body would exceed the per-response token cap (#393). The call is recorded through `maybe_capture` so a `SUMO_QA_DEBUG_DIR` capture contains the skill-tool (routing) calls the #214 conformance - fixtures check — without it a real capture could never satisfy an + fixtures check - without it a real capture could never satisfy an `expected_entry_skill` contract. The captured output is a compact summary, not the served body (which can be ~12k tokens).""" - body_fn = _make_skill_callable(path, token_cap=token_cap, profile=profile) + body_fn = _make_skill_callable(path, token_cap=token_cap) def fn() -> str: text = body_fn() diff --git a/src/sumo_qa/skill_resources.py b/src/sumo_qa/skill_resources.py index 4a84ecef..14783c35 100644 --- a/src/sumo_qa/skill_resources.py +++ b/src/sumo_qa/skill_resources.py @@ -114,10 +114,7 @@ def skill_module_resource(skill_name: str, module_id: str) -> str: name="sumo-qa skill full body", description=( "The entire SKILL.md body for one skill (mode='full'), " - "byte-for-byte identical to the existing zero-argument skill tool " - "under the default output profile (a non-default " - "SUMO_QA_OUTPUT_PROFILE overlays the skill tool only, #215; this " - "resource always serves the canonical body). " + "byte-for-byte identical to the existing zero-argument skill tool. " "A body over the host's per-response token cap is returned as an " "oversize pointer to the progressive-loading slices instead (#393)." ), diff --git a/tests/test_skill_prompts.py b/tests/test_skill_prompts.py index 242893ce..7571b0bb 100644 --- a/tests/test_skill_prompts.py +++ b/tests/test_skill_prompts.py @@ -54,18 +54,14 @@ def test_no_skill_registered_as_a_prompt() -> None: assert not leaked, f"Skills leaked into MCP prompts: {leaked}" -def test_skill_tool_body_matches_skill_md_content(monkeypatch) -> None: +def test_skill_tool_body_matches_skill_md_content() -> None: """Calling each skill tool returns the full SKILL.md content, read fresh from disk on each invocation (single source of truth), UNLESS the body exceeds the per-response token cap (#393), in which case the tool returns a compact progressive-loading pointer instead of the over-cap body the host - would refuse. Pinned with the default profile: the body must be EQUAL to - the SKILL.md text (byte-for-byte), not merely contain it, so an overlay - wrongly prepended on the default path fails through the real - registration path.""" + would refuse.""" from sumo_qa.skill_prompts import DEFAULT_SKILL_RESPONSE_TOKEN_CAP, _approx_tokens - monkeypatch.delenv("SUMO_QA_OUTPUT_PROFILE", raising=False) server = build_mcp_server() async def collect() -> dict[str, str]: @@ -107,9 +103,8 @@ async def collect() -> dict[str, str]: f"tool {tool_name!r} pointer does not name the progressive-loading route" ) else: - assert bodies[tool_name] == expected_text, ( - f"tool {tool_name!r} body is not byte-for-byte the SKILL.md " - f"content under the default profile" + assert expected_text in bodies[tool_name], ( + f"tool {tool_name!r} body does not contain SKILL.md content" ) @@ -267,250 +262,3 @@ def test_skill_tool_description_matches_frontmatter() -> None: f"tool {tool_name!r} description mismatch: " f"expected={expected_collapsed!r} got={tool.description!r}" ) - - -# --------------------------------------------------------------------------- -# Output-profile overlay (issue #215) -# -# SUMO_QA_OUTPUT_PROFILE=concise|default|strict tunes how much ceremony wraps a -# served skill body WITHOUT editing any SKILL.md (a shared serve-time overlay, -# not a per-skill rewrite). `default` must serve the body byte-for-byte -# (backwards compatible); `concise`/`strict` prepend a small, bounded overlay -# that reshapes output but can never downgrade a mandatory gate. -# --------------------------------------------------------------------------- - - -def test_default_profile_serves_body_byte_for_byte(tmp_path, monkeypatch) -> None: - """With the profile unset (or `default`), the served body is the SKILL.md - content byte-for-byte — no overlay, no drift from current behavior.""" - from sumo_qa.skill_prompts import _make_skill_callable - - monkeypatch.delenv("SUMO_QA_OUTPUT_PROFILE", raising=False) - skill_dir = tmp_path / "my-skill" - skill_dir.mkdir() - body = "---\ndescription: d\n---\n# Body\n\nsome content\n" - (skill_dir / "SKILL.md").write_text(body, encoding="utf-8") - - fn = _make_skill_callable(skill_dir / "SKILL.md") - assert fn() == body - - -def test_default_profile_explicit_value_is_byte_for_byte(tmp_path) -> None: - """An explicit `default` override behaves identically to unset.""" - from sumo_qa.skill_prompts import _make_skill_callable - - skill_dir = tmp_path / "my-skill" - skill_dir.mkdir() - body = "---\ndescription: d\n---\n# Body\n" - (skill_dir / "SKILL.md").write_text(body, encoding="utf-8") - - fn = _make_skill_callable(skill_dir / "SKILL.md", profile="default") - assert fn() == body - - -def test_concise_profile_prepends_overlay_before_body(tmp_path) -> None: - """`concise` prepends the concise overlay, then the untouched body.""" - from sumo_qa.skill_prompts import _CONCISE_OVERLAY, _make_skill_callable - - skill_dir = tmp_path / "my-skill" - skill_dir.mkdir() - body = "---\ndescription: d\n---\n# Body\n" - (skill_dir / "SKILL.md").write_text(body, encoding="utf-8") - - fn = _make_skill_callable(skill_dir / "SKILL.md", profile="concise") - out = fn() - assert out.startswith(_CONCISE_OVERLAY) - assert out.endswith(body) - assert "concise" in _CONCISE_OVERLAY.lower() - - -def test_strict_profile_prepends_overlay_before_body(tmp_path) -> None: - """`strict` prepends the strict overlay, then the untouched body.""" - from sumo_qa.skill_prompts import _STRICT_OVERLAY, _make_skill_callable - - skill_dir = tmp_path / "my-skill" - skill_dir.mkdir() - body = "---\ndescription: d\n---\n# Body\n" - (skill_dir / "SKILL.md").write_text(body, encoding="utf-8") - - fn = _make_skill_callable(skill_dir / "SKILL.md", profile="strict") - out = fn() - assert out.startswith(_STRICT_OVERLAY) - assert out.endswith(body) - assert "strict" in _STRICT_OVERLAY.lower() - - -def test_env_var_selects_profile_at_call_time(tmp_path, monkeypatch) -> None: - """The env var (not just the explicit param) selects the profile, resolved - fresh on each call so a host config change takes effect without a rebind.""" - from sumo_qa.skill_prompts import _CONCISE_OVERLAY, _make_skill_callable - - skill_dir = tmp_path / "my-skill" - skill_dir.mkdir() - body = "---\ndescription: d\n---\n# Body\n" - (skill_dir / "SKILL.md").write_text(body, encoding="utf-8") - - fn = _make_skill_callable(skill_dir / "SKILL.md") # no explicit override - monkeypatch.setenv("SUMO_QA_OUTPUT_PROFILE", "concise") - assert fn().startswith(_CONCISE_OVERLAY) - monkeypatch.delenv("SUMO_QA_OUTPUT_PROFILE", raising=False) - assert fn() == body - - -def test_invalid_profile_falls_back_to_default(tmp_path, monkeypatch) -> None: - """An unrecognised profile value falls back predictably to `default` - (byte-for-byte body) rather than raising — a typo can never break serving - or silently drop a gate.""" - from sumo_qa.skill_prompts import _make_skill_callable - - skill_dir = tmp_path / "my-skill" - skill_dir.mkdir() - body = "---\ndescription: d\n---\n# Body\n" - (skill_dir / "SKILL.md").write_text(body, encoding="utf-8") - - monkeypatch.setenv("SUMO_QA_OUTPUT_PROFILE", "verbose-plz") - fn = _make_skill_callable(skill_dir / "SKILL.md") - assert fn() == body - - -def test_resolve_output_profile_normalises_case_and_whitespace(monkeypatch) -> None: - """Resolution is case/whitespace-insensitive so ` Concise ` == `concise`.""" - from sumo_qa.skill_prompts import _resolve_output_profile - - monkeypatch.delenv("SUMO_QA_OUTPUT_PROFILE", raising=False) - assert _resolve_output_profile(" Concise ") == "concise" - assert _resolve_output_profile("STRICT") == "strict" - assert _resolve_output_profile() == "default" - - -def test_resolve_output_profile_invalid_explicit_override(monkeypatch) -> None: - """An invalid EXPLICIT override also falls back to default (same predictable - rule as the env path).""" - from sumo_qa.skill_prompts import _resolve_output_profile - - monkeypatch.delenv("SUMO_QA_OUTPUT_PROFILE", raising=False) - assert _resolve_output_profile("nonsense") == "default" - - -def test_concise_and_strict_overlays_preserve_mandatory_gates(tmp_path) -> None: - """Every non-default overlay must restate the never-optional floor so a - high-risk workflow keeps its gates in concise mode: Iron Law / HARD-GATE, - evidence for claims, and confirmation before writes or installs. This is the - safety invariant behind the issue's non-goal 'No profile may allow skipping - required tests, evidence, confirmations, or safety gates.'""" - from sumo_qa.skill_prompts import _CONCISE_OVERLAY, _STRICT_OVERLAY - - for overlay in (_CONCISE_OVERLAY, _STRICT_OVERLAY): - low = overlay.lower() - assert "iron law" in low - assert "hard-gate" in low - assert "evidence" in low - assert "confirm" in low - assert "install" in low - - -def test_overlays_stay_within_a_bounded_token_budget() -> None: - """Concise must reduce output and strict must not bloat payloads, so the - overlay itself is a small bounded constant — pin a ceiling so it cannot grow - into a payload of its own.""" - from sumo_qa.skill_prompts import ( - _CONCISE_OVERLAY, - _STRICT_OVERLAY, - _approx_tokens, - ) - - for overlay in (_CONCISE_OVERLAY, _STRICT_OVERLAY): - assert _approx_tokens(overlay) <= 250, ( - f"profile overlay is ~{_approx_tokens(overlay)} tokens (>250); " - f"keep it a compact directive, not a second payload" - ) - - -def test_over_cap_skill_under_profile_returns_overlaid_pointer(tmp_path) -> None: - """When the composed (overlay + body) exceeds the per-response token cap, the - tool still degrades to the progressive-loading pointer (#393) rather than - the over-cap body — and the profile overlay is preserved on the pointer so - the host still knows the active profile, because overlay + pointer fits - this cap (~358 tokens composed vs a 400 cap).""" - from sumo_qa.skill_prompts import _CONCISE_OVERLAY, _approx_tokens, _make_skill_callable - - skill_dir = tmp_path / "big-skill" - skill_dir.mkdir() - body = "---\ndescription: d\n---\n# Body\n" + ("x " * 5000) - (skill_dir / "SKILL.md").write_text(body, encoding="utf-8") - - fn = _make_skill_callable(skill_dir / "SKILL.md", token_cap=400, profile="concise") - out = fn() - assert out.startswith(_CONCISE_OVERLAY) - assert "sumo_qa_load_skill_context" in out - assert body not in out - assert _approx_tokens(out) <= 400 - - -def test_overlaid_pointer_never_exceeds_cap(tmp_path) -> None: - """With a cap the bare pointer fits under but overlay + pointer does NOT - (cap 200: pointer ~183 tokens, overlay ~176, composed ~358), the overlay is - dropped rather than recreating the over-cap response the pointer exists to - prevent (#393). A broken implementation that always prepends the overlay - returns ~358 tokens against a 200 cap; the correct one returns the in-cap - pointer alone.""" - from sumo_qa.skill_prompts import _CONCISE_OVERLAY, _approx_tokens, _make_skill_callable - - skill_dir = tmp_path / "big-skill" - skill_dir.mkdir() - body = "---\ndescription: d\n---\n# Body\n" + ("x " * 5000) - (skill_dir / "SKILL.md").write_text(body, encoding="utf-8") - - fn = _make_skill_callable(skill_dir / "SKILL.md", token_cap=200, profile="concise") - out = fn() - assert _approx_tokens(out) <= 200 - assert "sumo_qa_load_skill_context" in out - assert not out.startswith(_CONCISE_OVERLAY) - - -def test_over_cap_skill_default_profile_pointer_unchanged(tmp_path) -> None: - """Default profile over-cap path is byte-for-byte the existing pointer — no - overlay leaks into the default degraded response.""" - from sumo_qa.skill_prompts import ( - _approx_tokens, - _make_skill_callable, - _oversize_pointer_text, - ) - - skill_dir = tmp_path / "big-skill" - skill_dir.mkdir() - body = "---\ndescription: d\n---\n# Body\n" + ("x " * 5000) - (skill_dir / "SKILL.md").write_text(body, encoding="utf-8") - - fn = _make_skill_callable(skill_dir / "SKILL.md", token_cap=100) - expected = _oversize_pointer_text("big-skill", _approx_tokens(body), 100) - assert fn() == expected - - -def test_register_threads_profile_through_to_tool(tmp_path, monkeypatch) -> None: - """register_skills_as_prompts binds the serving callable; with the env - profile set, each bound tool serves the overlaid body.""" - from unittest.mock import MagicMock, patch - - from sumo_qa.skill_prompts import _CONCISE_OVERLAY, register_skills_as_prompts - - skill_dir = tmp_path / "my-skill" - skill_dir.mkdir() - (skill_dir / "SKILL.md").write_text("---\ndescription: d\n---\n# Body\n", encoding="utf-8") - - captured = {} - - def fake_tool(name, description): - def decorator(fn): - captured["fn"] = fn - return fn - - return decorator - - mcp = MagicMock() - mcp.tool.side_effect = fake_tool - monkeypatch.setenv("SUMO_QA_OUTPUT_PROFILE", "concise") - with patch("sumo_qa.skill_prompts._skills_dir", return_value=tmp_path): - register_skills_as_prompts(mcp) - - assert captured["fn"]().startswith(_CONCISE_OVERLAY) From f3c63862ce0e22587ef68338781ebf2ac0668364 Mon Sep 17 00:00:00 2001 From: sumithr <38540179+sumithr@users.noreply.github.com> Date: Mon, 20 Jul 2026 12:01:29 +0200 Subject: [PATCH 2/2] test(skill-serving): pin byte-for-byte serving with exact equality, guard the removed env var Codex P2 on #556: the reverted body-match test used 'in' (contains), which would accept a reintroduced overlay wrapper and defeat the byte-for-byte serving contract this revert establishes. Restore exact equality, and add a guard that SUMO_QA_OUTPUT_PROFILE stays inert so the removed feature cannot silently return. --- tests/test_skill_prompts.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/tests/test_skill_prompts.py b/tests/test_skill_prompts.py index 7571b0bb..23ca04aa 100644 --- a/tests/test_skill_prompts.py +++ b/tests/test_skill_prompts.py @@ -103,11 +103,32 @@ async def collect() -> dict[str, str]: f"tool {tool_name!r} pointer does not name the progressive-loading route" ) else: - assert expected_text in bodies[tool_name], ( - f"tool {tool_name!r} body does not contain SKILL.md content" + assert bodies[tool_name] == expected_text, ( + f"tool {tool_name!r} body is not byte-for-byte the SKILL.md content" ) +def test_output_profile_env_is_inert_after_revert(tmp_path, monkeypatch) -> None: + """The output-profile feature was removed (#556 reverts #215/#471). Setting + SUMO_QA_OUTPUT_PROFILE must have NO effect: the served body stays byte-for-byte + the SKILL.md content. This guards against a silent reintroduction of a + serve-time overlay under the old env var.""" + from sumo_qa.skill_prompts import _make_skill_callable + + skill_dir = tmp_path / "skill" + skill_dir.mkdir() + raw = "---\ndescription: d\n---\n# Body\n" + "word " * 40 + (skill_dir / "SKILL.md").write_text(raw, encoding="utf-8") + + assert _make_skill_callable(skill_dir / "SKILL.md")() == raw + for value in ("concise", "strict", "lean", "nonsense"): + monkeypatch.setenv("SUMO_QA_OUTPUT_PROFILE", value) + assert _make_skill_callable(skill_dir / "SKILL.md")() == raw, ( + f"SUMO_QA_OUTPUT_PROFILE={value!r} changed the served body; " + f"the removed profile feature must stay inert" + ) + + # --------------------------------------------------------------------------- # Branch coverage for skill_prompts.py # ---------------------------------------------------------------------------