Repository navigation
fix(tier2): derive the intra-skill scalar budget from the chunk ceiling - #270
Conversation
Tier 2 context deduplication allows 512 content chunks per skill, but a separate, fixed scalar-comparison budget of 25,000,000 rejected far smaller skills. The budget is pair count times embedding width, so 2,048-dimensional embeddings hit it at 157 chunks and 1,536-dimensional embeddings at 181. A valid skill above that size failed `validate` with a blocking CRITICAL `scalar_comparison_limit` finding. The clustering guard in `build_clusters` carried its own copy of the same budget. Derive the budget from the chunk ceiling instead: 512 chunks times 2,048 dimensions, or 267,911,168 scalar comparisons, defined once in constants.py and shared by the validator and the clustering guard. Embeddings of up to 2,048 dimensions now reach all 512 chunks. Wider embeddings get a lower effective chunk limit (418 at 3,072 dimensions, 362 at 4,096), computed exactly with integer arithmetic. The finding now reports the effective limit for the validator's actual budget in its message and metadata, so authors know how far to shrink the skill. The chunk ceiling, the early stop after the first embedding batch and every other Tier 2 guard are unchanged. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
rng1995
left a comment
There was a problem hiding this comment.
Review summary: no findings (no P1/P2/P3).
Checked: 512511/22048 = 267,911,168 and effective_chunk_limit (exact isqrt bound; 512/511/418/362 at 2048/2049/3072/4096), that the validator and build_clusters now share the one constant (the only remaining 25,000,000 is the separate plugin-bundle budget, as the description says), the extra finding metadata and message, the docs table, and the CHANGELOG placement.
Local verification (head 1412dff): ruff check clean; pytest tests/deduplication tests/embedding: 489 passed, 2 skipped.
Reviewed with Claude Code.
1412dff to
8b93588
Compare
Conflicts: src/skillevaluator/deduplication/intra_skill/intra_skill_validator.py, tests/deduplication/intra_skill/test_intra_skill_validator.py Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
chrisknvidia
left a comment
There was a problem hiding this comment.
The change is correct and I found nothing blocking. The new effective_chunk_limit is an exact integer bound (the largest n with n(n-1)/2 times the width within the budget), the validator and build_clusters now read the same constant, and the plugin path keeps its smaller per-skill budget so it still stays under the clustering guard. I also timed build_clusters at the new ceiling: about 2 s for 512 chunks at 2,048 dimensions. One small suggestion on the error message.
Conflicts: CHANGELOG.md, tests/deduplication/intra_skill/test_intra_skill_validator.py. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
The scalar_comparison_limit incomplete-scan error and its work_limit record named the effective chunk limit but not how many chunks the skill has, so an author still had to work out how far over the limit it was. Add the count to the error text and a chunk_count key to work_limit. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
* docs(changelog): move entries released in 0.7.0-0.7.2 out of Unreleased 0.7.0 (#314) and 0.7.1 (#327) never cut their sections on main, and 0.7.2 (#335) added its section below the whole Unreleased block, so Unreleased still listed work that had already shipped. Place each Unreleased entry under the release that shipped the PR that added it: - 0.7.0: the published section from the 0.7.0 tag, verbatim. It already holds the six entries that main had filed under 0.6.0, so 0.6.0 again matches the v0.6.0 tag, including the original run_config.json entry. - 0.7.1: #264 #271 #274 #281 #284 #289 #293 #299 #316 #317 #318 #323 #324 #326 #327, plus the #320 wording of the Windows Git-root entry, since #320 changed that 0.7.0 fix in 0.7.1. - 0.7.2: #263 #265 #269 #270 #276 #279 #287 #290 #296 #309 #328 #330 merged with the existing #335 entries. Only post-v0.7.2 entries stay under Unreleased, with one heading per subsection. Entry text is unchanged, apart from the published tag wording in 0.7.0 and 0.6.0. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * chore(release): prepare v0.8.0 Set the package, fallback, lock, citation and developer-guide versions to 0.8.0 and move every entry merged since v0.7.2 under '## 0.8.0 - 2026-11-05', leaving Unreleased empty. The refusal-fallback documentation test now reads the release section that names CLAUDE_CODE_DISABLE_REFUSAL_FALLBACK, requires it to be 0.8.0, and requires exactly one entry there to name the switch. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * chore(release): pin the verified 0.8.0 Tier 1 image and add its CI bundle Pin onboarding to the Tier 1 image published by the reviewed main revision 55d2d04 in "Build and publish Tier 1 image" run 42158955180: ghcr.io/nvidia/skillevaluator-tier1@sha256:9d5483243918937be4f2178f74cf7c622a531dee41e3176906994d52fa14950a (config sha256:d17d6f5105ec5f1bf0cbe4dff0d693aae4ecf01e9c1c6a6ddb7830518acace33). The workflow and publisher refs both move to 55d2d04. ci/bundles/0.8.0 mirrors the 0.7.2 bundle. The templates, README and release.json are the run's github-actions-onboarding artifact and match ci/render_templates.py output for these pins byte for byte. The scanner inventory and verification receipt come from the build's runtime-stage version step, the five-case smoke receipt, the onboarding job's anonymous pull, and the public manifest, whose config digest equals the smoke-tested image ID. The ZIP uses the 0.7.2 layout (sorted members, inner checksums, 1980 timestamps, 0644, deflate level 9) and rebuilds to identical bytes. Point the current-bundle links at 0.8.0 and list 0.7.2 as historical. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Narendran Raghavan <[email protected]> --------- Signed-off-by: Narendran Raghavan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
Tier 2 context deduplication has two limits on the all-pairs clustering work for one skill. The first is a 512-chunk ceiling, checked before any embedding request. The second is a scalar-comparison budget, defined as pair count times embedding width. The second was hard-coded to 25,000,000, in both the validator and the clustering guard in
build_clusters. That is far below what the chunk ceiling implies, so valid skills were rejected long before they reached 512 chunks.This PR:
constants.pyand derives it from the chunk ceiling:CONTENT_DEDUP_MAX_PAIR_COMPARISONS(512 × 511 / 2) ×CONTENT_DEDUP_SCALAR_BUDGET_DIMENSION(2,048) = 267,911,168. Embeddings of up to 2,048 dimensions can now use all 512 chunks.IntraSkillValidator(its default budget) andbuild_clusters(its defensive guard) both read that one constant, so the clustering step accepts every workload the validator allows.effective_chunk_limit(vector_dimension, max_scalar_comparisons=None), an exact integer (math.isqrt) bound that gives the largest chunk count allowed for a given width and budget. With the default budget: 511 at 2,049 dimensions, 418 at 3,072, 362 at 4,096.scalar_comparison_limitfinding's message and to its metadata (effective_chunk_limit), so an author knows how far to shrink the skill. The finding uses the validator's actual budget, so a smaller private per-skill budget reports its own limit.docs/tier2-deduplication.mdxand adds aCHANGELOG.mdentry under Unreleased → Fixed.The chunk ceiling, the LLM-cluster limit, the cluster-member and prompt-size guards, the collection limits and the other Tier 2 guards are unchanged.
Scope notes:
build_clusters, and bounds cluster members and LLM prompt sizes. This PR keeps all of that and only changes the budget value, where it is defined, and the finding's detail.deduplication/plugin/commands.pykeeps its own aggregateMAX_PLUGIN_DEDUP_SCALAR_COMPARISONSbudget, split across bundled skills. It has no public dispatch, and this PR does not change it.constants.py. Whichever lands second resolves a small conflict around that constant and the finding.Why
Before this PR, a skill failed Tier 2 with a CRITICAL
scalar_comparison_limitfinding at:Both widths of the default embedding setups fail well below the 512-chunk ceiling. The 2,048-dimensional case is the default NVIDIA Build embedding model, and 1,536 is OpenAI
text-embedding-3-small.validateruns deduplication by default and Tier 2 gates by default, so these skills got a non-zero exit. A 363-chunk skill, for example, failed at every common width. Main now stops after the first embedding batch, which saves the remaining requests, but the skill still fails.After this PR, embeddings of up to 2,048 dimensions reach the full 512 chunks. Wider models are still bounded, and the finding names the limit that applies to them.
The cost is runtime: skills that used to fail now run the full all-pairs clustering. With main's normalize-once clustering, a local measurement of
build_clusterstook about 3 s of CPU for 512 chunks at 2,048 dimensions, 1.4 s for 363 chunks at 2,048, and 2.7 s for 418 chunks at 3,072.No public issue tracks this bug.
Kept from public
embedding-providerincomplete scan, no skill finding), vector validation, and the check order are all kept._max_scalar_comparisons,_max_total_prompt_chars) andmax_llm_clustersare kept. Only the default scalar budget changes.effective_chunk_limitmetadata key. It keeps the privacy-safefile_path(the skill directory name, not a host path), its severity and check name, the existingpair_count,vector_dimension,scalar_workandlimitmetadata, and its suggestion.build_clusterskeeps its normalize-once loop, split-piece handling and both guards. Only its budget now comes fromconstants.py. The chunker and thesimilarity-checkscalar budget (--max-scalar-comparisons) are not touched.raising=False, because the constant is now a real import, and it asserts the new metadata key.Tests
tests/deduplication/intra_skill/test_intra_skill_validator.py:chunk_count_limitbefore any embedding request.effective_chunk_limittests:tests/deduplication/intra_skill/test_semantic_clustering.py:build_clustersuses the same budget as the validator.build_clustersaccepts 157 chunks at 2,048 dimensions (25,079,808 scalar comparisons), which the former fixed budget rejected.main, the 363-chunk, 512-chunk, wide-embedding, explicit-budget and clustering regressions fail and the new helper does not exist. All of them pass with this change.pytest tests/deduplication: 245 passed, 1 skipped.tests/embedding,tests/inference/test_llm_client.py,tests/golden,tests/reporting,tests/test_cli.py,tests/test_commands.py,tests/test_publication_evidence.py,tests/test_tier2_command_failures.pyandtests/validators/test_similarity.py.ruff checkandruff format --checkpass on the changed Python files.scripts/check_oss_boundary.pypasses, andgit diff --checkis clean.🤖 Generated with Claude Code