Skip to content

fix(tier2): stop catalog queries from matching a skill against its own entry - #296

Merged
rng1995 merged 6 commits into
mainfrom
naren/port-tier2-catalog-self-duplicate
Nov 3, 2026
Merged

rng1995 merged 6 commits into
mainfrom
naren/port-tier2-catalog-self-duplicate

Conversation

@rng1995

@rng1995 rng1995 commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

similarity-check --catalog and tier2 --catalog compare one skill with every entry of a saved local catalog. When that skill is already in the catalog, which is the normal case when a team re-screens its own skills, it matched its own entry with a score of 1.0. The result reported it as an EXACT_DUPLICATE of itself (CRITICAL) and the run failed.

This change skips the one catalog entry that records the target itself, and only with positive evidence that the target sits in the tree the catalog was built from:

  • EmbeddingRegistry.catalog_self_entry(target) finds that entry. Catalogs store paths relative to a scan root they do not record. An entry counts as the target only when all three of these hold:
    • Its content fingerprint matches the target in the registry's mode: name plus description, or the whole SKILL.md with --full-body.
    • Its path ends the target's resolved directory path. The longest such path wins. This infers the scan root, for example ./skills for ./skills/alpha and catalog path alpha.
    • Of up to eight other catalog skills, read in path order under that inferred root, more than half are present at their recorded paths with matching fingerprints, through no links. Skills that contain the target or are nested inside it are not checked, because a copied folder carries them too.
  • A root (.) entry and a catalog with no other skill entry never match. A target path that differs from the catalog only in letter case matches when both spellings name the same directory, as on a case-insensitive filesystem.
  • EmbeddingRegistry.query_entry gains a keyword-only exclude_entry_id. It skips that entry before the threshold and the match limit apply.
  • SimilarityValidator uses both. Its catalog_compared success detail records self_matches_excluded and excluded_catalog_paths, so every skip shows up in the JSON report. Its message names the skipped entry.

The tree check matters because Tier 1 requires a skill's directory name to equal its frontmatter name. A conformant verbatim copy therefore always ends in the same directory name as the original. Path suffix plus fingerprint alone would treat any same-name, same-description skill as the catalog's own entry, whether it is a copy in a staging folder, in another repository, or a new nested skill.

Why

Re-screening skills that are already in the catalog is a natural CI pattern: build the catalog once, then check each changed skill against it. Every such run failed with a false CRITICAL finding. A catalog entry holds only a relative path and a content fingerprint, so nothing downstream could tell the skill's own row from a real duplicate.

With this fix, an unchanged skill passes, in the tree the catalog was built from or in another checkout of it. So does a skill whose edits leave the compared content unchanged, such as a body-only edit in the default description mode. Real duplicates outside that tree still fail the run.

The table shows public main and this branch, run through the CLI with a deterministic embedding stub. The catalog is built from repo/skills/{alpha,beta}. candidates/alpha is a verbatim copy that passes Tier 1, and second-checkout is a full copy of repo.

Target main this branch
repo/skills/alpha (already in the catalog) exit 1, EXACT_DUPLICATE against alpha exit 0, excluded_catalog_paths: ["alpha"]
second-checkout/skills/alpha (another checkout) exit 1, EXACT_DUPLICATE against alpha exit 0, excluded_catalog_paths: ["alpha"]
candidates/alpha (verbatim copy) exit 1, EXACT_DUPLICATE against alpha exit 1, EXACT_DUPLICATE against alpha

Limitations

  • A copy of most of the catalog's tree counts as the same tree. This includes a second checkout, or a fork whose skills are unchanged, so a verbatim copy inside such a tree is skipped. A copy of only a few catalog skills is not enough.
  • If more than half of the checked other skills changed or were removed since the catalog was built, the skill's own entry is compared again and the old finding returns. Rebuilding the catalog from the tree being screened avoids this.
  • A catalog with only one skill entry never skips it, so re-screening that one skill still reports it.
  • An edited skill whose name, description, or (with --full-body) SKILL.md changed no longer matches its old entry and is compared with it as before.

Kept from public

  • All catalog hardening stays unchanged: the bounded, no-follow catalog reader, exact schema and field validation, schema version 1 (no catalog format change), and the provider, model, mode and endpoint compatibility checks. The match limit and scalar-work budgets also stay as they are.
  • The tree check reads each sampled skill with the existing bounded, no-follow extract_from_skill. Every path component below the inferred root is checked for links first. At most eight manifests are read, each capped at the per-file manifest limit, and any read error counts as absent.
  • The fix uses identity data the catalog already holds (relative path plus content fingerprint), so there is no new CLI option and no schema bump.

Relation to main and open PR #28

Tests

  • tests/embedding/test_catalog.py::TestCatalogSelfEntry runs against real saved and reloaded catalogs:
    • An existing skill skips only its own entry, and matches it without the exclusion.
    • Another checkout of the catalog tree skips its own entry, in description and full-body modes.
    • Verbatim copies that pass Tier 1 are still EXACT_DUPLICATE in both modes. The cases are a copy at candidates/alpha, a copy at other-repo/skills/alpha, a renamed copy, and a new nested skills/team/alpha with the same name and description.
    • Copies of only two of five catalog skills are not treated as the catalog tree. A tree where one of four other skills was edited still is.
    • These never count as evidence: a catalog with no other skill entry, skills nested inside the copied target, and a linked catalog skill.
    • At most eight other skills are read.
    • The longest catalog path wins when a catalog built from a repository root has skills/alpha and vendor/skills/alpha.
    • Edited skills are excluded after a body-only edit in description mode, and compared after a description edit or any full-body edit.
    • A root (.) entry never identifies the target.
    • Letter case: a differently cased path to the same directory matches on a case-insensitive filesystem. On a case-sensitive one, a separate directory that differs only in case is reported.
  • tests/validators/test_similarity.py::TestCatalogSelfEntry is an end-to-end SimilarityValidator run (save catalog, then query). The existing skill passes with the exclusion recorded, and conformant copies at candidates/alpha and other-repo/skills/alpha fail. Two mocked catalog tests now assert the new query_entry call.
  • The new tests fail on unmodified public main. The copy regression tests also fail against a suffix-plus-fingerprint rule without the tree check.
  • pytest tests/validators/test_similarity.py tests/embedding tests/deduplication tests/cli/test_tier_workflows.py tests/test_tier2_command_failures.py tests/test_publication_evidence.py tests/test_commands.py tests/test_cli.py tests/reporting/test_reporters.py tests/test_oss_packaging.py: all pass.
  • ruff check and ruff format --check pass on the changed Python files, and so does scripts/check_oss_boundary.py.

🤖 Generated with Claude Code

rng1995 and others added 2 commits October 30, 2026 12:00
…n entry

similarity-check --catalog and tier2 --catalog compare one skill with
every entry of a saved local catalog. When the skill was already in the
catalog, for example when a team re-screens its own skills in CI, it
matched its own entry with a score of 1.0 and was reported as a CRITICAL
EXACT_DUPLICATE of itself, failing the run.

Catalogs store only paths relative to an unrecorded scan root plus a
content fingerprint, so identify the target's own entry from that data:
the entry with the longest catalog path that ends the target's resolved
directory path, accepted only when its fingerprint matches in the
registry's mode. A root (".") entry carries no path evidence and never
matches. query_entry skips that one entry before thresholds apply, and
the catalog_compared result records self_matches_excluded and
excluded_catalog_paths.

Copies and same-name skills at other paths are still reported. A skill
whose compared content changed is still compared with its old entry;
the docs suggest building the catalog from the tree being screened.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The self-entry rule matched the longest catalog path that ends the
target's path plus the content fingerprint. Tier 1 requires a skill's
directory name to equal its frontmatter name, so a conformant verbatim
copy always ends in the same directory name as the original. For a
catalog built from a flat skills folder, any same-name, same-description
skill anywhere, such as a copy in a staging folder or another
repository, was skipped as the catalog entry itself and its
EXACT_DUPLICATE was hidden.

Require positive evidence that the target sits in the tree the catalog
was built from. Strip the matched catalog path from the resolved target
to infer the scan root, then read up to eight other catalog skills in
path order under that root, through no links. More than half must be
present at their recorded paths with matching fingerprints. Skills that
contain the target or are nested inside it are not checked, because a
copied folder carries them too. A catalog with no other skill entry
never skips one. A second checkout of the same tree still counts as
the same tree.

A target path spelled with a different letter case now also matches
its entry when both spellings name the same directory, as on a
case-insensitive filesystem.

Add regression tests for Tier-1-conformant copies in a staging folder,
in another repository and as a new nested same-name skill, in
description and full-body modes, plus a second checkout, partial copies,
nested skills, linked skills, the sample bound and letter case.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review summary: no findings.

Checked catalog_self_entry (fingerprint in the registry's mode, longest-suffix scan-root inference, root and single-skill-catalog exclusions, case-only path differences via samestat), _holds_catalog_tree (bounded sample of 8, majority rule, no-link checks, nested and ancestor entries skipped, read errors counted as absent), the exclude_entry_id handling in query_entry (applied before threshold and match limit), catalog path validation (no absolute or .. components, so the sampled reads stay under the inferred root), the SimilarityValidator metadata and message, and the CHANGELOG/docs entries. The fingerprint helper matches how entries are recorded at add time. tests/embedding and tests/validators/test_similarity.py pass locally (301 passed, 1 skipped) and ruff check is clean.

Reviewed with Claude Code.

@chrisknvidia
chrisknvidia force-pushed the naren/port-tier2-catalog-self-duplicate branch from 0980467 to 309ef99 Compare October 30, 2026 22:24
Conflicts: CHANGELOG.md

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

@chrisknvidia chrisknvidia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read the new self-entry matching in the registry and the validator wiring end to end, and ran scratch catalogs through it: nested same-name skills, the longest-suffix case, copies in a staging folder, and linked skills. The matching logic holds up. Two non-blocking notes: the tree check only samples the first eight skills by path, which weakens the 'most of the tree' guarantee on bigger catalogs, and two mocked validator tests quietly take the new branch.

Comment thread tests/validators/test_similarity.py Resolved
rng1995 and others added 3 commits November 3, 2026 04:14
Conflicted files: CHANGELOG.md.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The catalog-tree check read the first eight other skills in path order, so
on a large catalog a staging folder with the target plus a few first-sorted
skills counted as the catalog's tree, and a checkout missing some of those
first skills did not. Sample up to eight other skills spread evenly across
the path-sorted list instead, keeping the read cap.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
test_catalog_extracts_only_the_root_skill and
test_catalog_finding_labels_target_and_catalog_roles left
catalog_self_entry unset, so the mock returned a MagicMock and the
validator queried with exclude_entry_id=<MagicMock>. Return None and
assert the plain query_entry call.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rng1995
rng1995 merged commit 9f520db into main Nov 3, 2026
21 checks passed
@rng1995
rng1995 deleted the naren/port-tier2-catalog-self-duplicate branch November 3, 2026 20:04
rng1995 added a commit that referenced this pull request Nov 6, 2026
* 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]>
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.

2 participants