Repository navigation
fix(tier2): reject out-of-range or non-string dedup LLM verdict fields - #412
Conversation
Context deduplication turned the chat-LLM reply into a finding with float(confidence) and the raw rationale and suggestion values. A confidence of 85 or true made a HIGH finding, the string "NaN" made a MEDIUM finding whose NaN confidence broke the strict JSON and SARIF reports, and a list or object in a text field reached the finding unchanged. Add parse_bounded_llm_verdict to the inference types. It requires a JSON object, a known verdict string, a finite numeric confidence within [0, 1] (not a bool or a string), and rationale and suggestion strings of at most 8,192 characters. analyze_cluster uses it, so a bad reply raises LLMClientError and the validator reports the cluster as a failed analysis, which leaves the scan incomplete. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Describe the confidence range and text-length checks on chat-LLM verdicts in the Tier 2 page and its limits table, and add a Fixed entry under Unreleased. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…omplete The Fixed entry implied that only DUPLICATE verdicts were affected. The checks apply to every verdict, so an INTENTIONAL_DETAIL or RELATED_BUT_DISTINCT reply with a null suggestion or a "0.9" string confidence, which passed on 0.8.0, now leaves Tier 2 incomplete, and so does a DUPLICATE reply with a "0.9" confidence. Say that the field rules apply when a field is present, since a missing confidence still reads as 0. Move the entry above the SHARED CONTENT entry so it no longer touches the hunk a sibling change adds below that entry. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
A reply that breaks the confidence or text-field rules now fails the cluster's analysis whatever its verdict. Pin that an INTENTIONAL_DETAIL reply with a null suggestion and a RELATED_BUT_DISTINCT reply with a "0.9" confidence, which both passed before, and a DUPLICATE reply with a "0.9" confidence, which made a HIGH finding, now leave the scan incomplete with no finding. Also pin that a DUPLICATE reply without a confidence still reads it as 0 and gives a MEDIUM advisory finding. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
A missing confidence still reads as 0, so a DUPLICATE verdict without one is MEDIUM, and a missing rationale or suggestion reads as empty. Say so, and say that a reply that breaks the rules fails the analysis whatever its verdict, including a null suggestion. Move the verdict text row above the total prompt row in the limits table, so it no longer touches rows a sibling change adds after that row. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
No file conflicted. Four files changed on both sides and merged automatically: - CHANGELOG.md: main's new Unreleased entries are kept. This branch's dedup verdict entry stays under Fixed, between the PII evidence_sha256 entry and the SHARED CONTENT numbering entry, as before. Each Unreleased subsection still has one heading. - docs/tier2-deduplication.mdx: main's CI, collection coverage and scale benchmark sections are kept next to this branch's verdict field rules and the verdict text row in the limits table. - src/skillevaluator/constants.py: main's SIGNAL_EVIDENCE_SOURCES and OpenClaw manifest constants are kept next to TIER2_LLM_MAX_RESPONSE_SCALAR_CHARS. - tests/deduplication/intra_skill/test_intra_skill_validator.py: main's end-of-file shell comment test is kept next to this branch's verdict validation tests. It mocks analyze_cluster, so the verdict checks do not affect it. 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.
Reviewed the complete production diff and regression coverage; checked typed verdict fields, finite unit-interval confidence, scalar limits, analyzer/schema behavior and incomplete-analysis propagation. No actionable findings.
Verification at unchanged head 7402aded5279cb1f3ef97824e2bc11c77f577f39: 20 existing CI checks succeeded and 2 were intentionally skipped, including the supported Python tests, lint/package and security/platform gates where applicable. Fresh git merge-tree --write-tree is clean against the frozen main commit ce52a09. No new local test run is claimed for this unchanged code.
Signed-off-by: Narendran Raghavan <[email protected]> # Conflicts: # CHANGELOG.md
rng1995
left a comment
There was a problem hiding this comment.
Integration review at 440a66e2adb04b64d66d98c92d2419724e17feff: resolved the actual CHANGELOG conflict while merging main a0b65a91d512fdc2254d2559900b6c30404218b8, retaining both independent entries. No additional production edit was made beyond the reviewed integration. Focused verification: 37 passed in 9.71s; make lint passed; pinned Fern 5.121.0 check passed with 0 errors and only the existing authenticated-redirect warning.
The candidate is merge-clean against explicitly audited main a0b65a91d512fdc2254d2559900b6c30404218b8; subsequent main checks are recorded where main advanced during external merges. The merge commit has DCO sign-off and was pushed normally after fresh open-PR and live-head checks. Fresh hosted CI is pending. No PR was merged by this review.
* fix(tier2): raise the intra-skill chunk ceiling to 1,024 A valid skill with 513 to 1,024 content chunks stopped context deduplication as incomplete, and with 2,048-dimensional embeddings the scalar budget allowed only 512 chunks. Raise CONTENT_DEDUP_MAX_CHUNKS to 1,024 and size the scalar-comparison budget for 1,024-dimensional vectors at that ceiling (536,346,624). Effective chunk limits become 1,024 up to 1,024 dimensions, 836 at 1,536, 724 at 2,048, 591 at 3,072 and 512 at 4,096, each at or above the old limit. The cluster member cap follows the chunk ceiling as before. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(tier2): document the 1,024-chunk intra-skill ceiling Update the limits table: 1,024 content chunks, a 536,346,624 scalar comparison budget with its effective chunk limit per embedding width, and 1,024 cluster members. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(changelog): note the 1,024-chunk intra-skill ceiling Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(tier2): pin where a 2,048-dimensional skill at the ceiling stops A skill with 1,024 chunks and 2,048-dimensional embeddings passes the chunk ceiling, sends one 64-chunk embedding batch and then stops with scalar_comparison_limit (effective limit 724). Before the ceiling rose it stopped before any embedding request with chunk_count_limit. The existing width test covers the low end of that band (725 chunks); this covers the top, which the CHANGELOG now describes. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(tier2): give the chunk limit of each default embedding model The limits table listed the effective chunk limit per embedding width but did not say which width the default models return. OpenAI's text-embedding-3-small returns 1,536 dimensions (836 chunks) and NVIDIA Build's nvidia/nemotron-3-embed-1b returns 2,048 (724 chunks), so a user on the defaults could read 1,024 as their limit. The row now names both, and the paragraph below it says that a default-width skill with 725 to 1,024 chunks stops after the first embedding batch. A test resolves each provider's default model, looks up its width and checks that the row gives that width's limit next to the model name. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(changelog): lead with the default models' chunk limits The entry opened with 1,024 chunks, which neither default embedding model reaches. It now gives 724 for NVIDIA Build's 2,048-dimensional default and 836 for OpenAI's 1,536-dimensional default, and says that a skill above its width's limit but within 1,024 chunks now stops after the first embedding batch with scalar_comparison_limit instead of before any embedding request with chunk_count_limit, with the same exit code. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(tier2): check the default-model docs entry without a new import The docs check used a regular expression, and its module-level import of re sat where the open plugin-evaluation PR adds its own imports, which added a conflict region between the two. Plain string checks on the comma-separated entry that names the model do the same job. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(tier2): name the OpenAI-compatible default's chunk limit The comparison-work row named the limits of the OpenAI and NVIDIA Build default embedding models but not the OpenAI-compatible default, nvidia/nvidia/nemotron-3-embed-1b. That is the same 2,048-dimensional model, so its limit is also 724, and a gateway user on the default could read 1,024 as their limit. The row and the paragraph below the table now name it. The docs check gains an openai-compatible case, which failed before this change because the row did not name the model. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(changelog): name the OpenAI-compatible default and embedding volume The entry gave the new limits for the OpenAI and NVIDIA Build default embedding models. It now also names the OpenAI-compatible default, the same 2,048-dimensional model with the same 724-chunk limit, and says that the most embedding input one skill can send doubles with the ceiling, from 512 to 1,024 texts (724 with either 2,048-dimensional default). Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Signed-off-by: Narendran Raghavan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]> # Conflicts: # docs/tier2-deduplication.mdx
rng1995
left a comment
There was a problem hiding this comment.
Concurrent-merge integration review at 14362c8297e14e7a8e3c0375a761110768423616: The actual Tier 2 docs conflict preserves both main’s frontmatter/name-description limits and the 1,024-chunk/scalar budget from externally merged #426. The external main merge and #426 squash remain in history. No production conflict required manual edits. Focused contracts: 55 passed in 8.30s. Lint passes; pinned Fern validation reports 0 errors and only the existing authenticated-redirect warning.
The signed-off fix was pushed normally after live open/head/base guards and clean merge checks against captured main b38b71be01f7fdf332e37efbfec49714f3939161 and actual base main at b38b71be01f7fdf332e37efbfec49714f3939161. Fresh exact-head hosted CI is pending. No PR was merged by this review.
Brings in #410, #412, #413, #419, #421, #425, #430 and #444. Conflicts: CHANGELOG.md (kept both Unreleased Fixed entries) and evaluation/options.py (kept main's tolerate_baseline_timeouts field and this PR's backend field). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Narendran Raghavan <[email protected]>
Summary
Context deduplication now checks each chat-LLM verdict before it becomes a finding.
parse_bounded_llm_verdictinskillevaluator.inference(withrequire_bounded_llm_string). It requires:verdictstring from the allowed set;confidencethat is a JSON number (not a bool or a string), finite and within [0, 1];rationale(or the legacyreasoning) andsuggestionstrings of at most 8,192 characters (TIER2_LLM_MAX_RESPONSE_SCALAR_CHARS).DUPLICATEverdict) and a missing text field as empty, as before.analyze_clusteruses it, so a bad reply raisesLLMClientError. The validator already turns that into a failed cluster analysis with the bounded "LLM configuration or response was invalid" diagnostic, so the scan is reported as incomplete.DUPLICATE. So some scans that passed onmainare now incomplete, which is a blocking error. Examples are anINTENTIONAL_DETAILorRELATED_BUT_DISTINCTreply with anullsuggestion or a"0.9"string confidence. Those verdicts never become findings, somainignored their fields. ADUPLICATEreply with a"0.9"confidence, anullsuggestion or a 9,000-character rationale also turns from a HIGH finding into an incomplete scan.docs/tier2-deduplication.mdx. CHANGELOG entry under Unreleased > Fixed, which also states the passed-to-incomplete change.The closed plugin-evaluation PR #28 carried a version of this fix inside its larger change; this PR lands the generic part on its own.
Why
analyze_clusterbuilt the verdict withfloat(data.get("confidence", 0.0))and passedrationaleandsuggestionthrough as they came. The verdict schema saysnumberandstring, but it sets no range, and endpoints without structured output (Bedrock, or after a schema downgrade) are not held to it. On currentmain:85(a percentage) ortruemakes a HIGH, blocking finding."NaN"becomes aNaNconfidence. The skill passes with a MEDIUM finding, and the JSON and SARIF reports then fail withValueError: Out of range float values are not JSON compliant."inf"gives a HIGH finding and the same report failure.rationaleorsuggestionreaches the finding metadata and suggestion unchanged, and a 200,000-character rationale is kept whole.The new checks fail closed whatever the verdict. A reply that breaks them is malformed whether or not it would become a finding, so it now fails the analysis instead of passing on a guess. The cost is the behavior change in the Summary: a non-finding verdict with a
nulltext field or a string confidence now leaves Tier 2 incomplete.Kept from public
mainstay as they are: the 64,000-character per-request budget (system prompt included), the 1,000,000-character total, the cluster member cap equal to the chunk ceiling, and the cluster count limit. All are checked before the first chat-LLM call and reported as an incomplete scan underwork_limit, not as CRITICAL findings.VERDICT_JSON_SCHEMArequest, the strict JSON decoding inextract_json_from_responseand thellm_refusedadvisory are unchanged.llm_failure_diagnostic,mark_scan_incomplete, thellm_analysismetadata) is unchanged; a rejected reply follows the same path as any other malformed reply.mainalready has a genericrequire_bounded_stringinskillevaluator/utils/structured_data.py, and the plugin analyzer indeduplication/plugin/llm_analyzer.pyhas its own verdict checks with its own 8,192-characterMAX_RESPONSE_SCALAR_CHARS. Both stay as they are. The new helper,require_bounded_llm_string, raisesLLMClientError, the erroranalyze_clusterdocuments and the analyzer tests pin. The validator would report aValueErrorfromrequire_bounded_stringwith the same diagnostic, so the helper does not change what users see. Plugin code is out of scope here.mainhas no gap there: passing the pre-rendered prompt intoanalyze_cluster(rendering is deterministic and the validator already measures the same prompt), the batch prompt helpers (the validator does these checks), therecommendationfield check (not in this schema) and the answering-model field onLLMVerdict.inference/types.pyorintra_skill/llm_analyzer.py.SIGNAL_EVIDENCE_SOURCESnear line 636 ofconstants.py, below this PR's constant at line 244. fix(tier2): retain trailing shell comments in deduplication #357 added a test near line 114 oftest_intra_skill_validator.py; it mocksanalyze_cluster, so the verdict checks do not affect it. This PR's tests sit aftertest_llm_error_is_incomplete_without_skill_finding, near line 1010.CHANGELOG.mdanddocs/tier2-deduplication.mdx, and the bounded YAML port adds a test near line 181 oftest_intra_skill_validator.py. This entry sits above theSHARED CONTENT nentry, and the new limits row sits above the "Intra-skill review prompts in total" row, so each pair merges without conflicts in either order (checked withgit merge-tree).Tests
tests/deduplication/intra_skill/test_intra_llm_analyzer.py, 29 new tests:NaN,inf, -0.1, 1.1, 85,true,"0.5","NaN",nulland10**400(10)reasoningrejected (1)nullrejected (4)tests/deduplication/intra_skill/test_intra_skill_validator.py, 8 new tests, all through the realanalyze_cluster:"NaN","Infinity",85ortrueconfidence leaves the scan incomplete with no finding, and the JSON report still renders (4)INTENTIONAL_DETAILreply with anullsuggestion, and aRELATED_BUT_DISTINCTorDUPLICATEreply with a"0.9"confidence, leave the scan incomplete with no finding (3)DUPLICATEreply without a confidence still gives a MEDIUM advisory finding with confidence 0, and the skill passes (1)src/frommainatd717f22cfand this PR's tests, 30 of the 37 new tests fail.mainaccepted the reply: 15 analyzer tests, plus the 7 incomplete-scan validator tests. Onmainthose validator scans endpassedfor"NaN"and for the two non-duplicate replies, andfailed(a HIGH finding) for the other four.nullor10**400confidence, a list ornullverdict, and the 4 replies that are not objects) also failed onmain, but with aTypeError,OverflowError,AttributeErroror a differentLLMClientErrormessage. The scan was incomplete onmaintoo, with the same diagnostic except for10**400, which got "Unexpected LLM request error". These tests pin the documentedLLMClientErrorcontract, not a change in what users see.main: the bounds (4), the 8,192-character limit (1), the defaults (1) and the MEDIUM finding for a missing confidence (1).tests/deduplication/intra_skill: 174 passed (test_intra_llm_analyzer.py66,test_intra_skill_validator.py91).tests/deduplication,tests/inference,tests/embedding,tests/validators/test_similarity.py,tests/validators/test_hygiene.py,tests/test_ci_workflows.pyand the docs and CHANGELOG readers (tests/ci/test_image_build.py,tests/test_harbor_claude_refusal_fallback.py,tests/test_oss_packaging.py,tests/test_ci_change_classifier.py,tests/tier3/test_private_loose_source.py,tests/test_accuracy_arithmetic.py,tests/test_tier3_public_runtime.py,tests/test_benchmark_rollout_docs.py): 1627 passed, 2 skipped.tests/reporting/test_reporters.py,tests/test_publication_evidence.py,tests/test_tier2_command_failures.pyandtests/test_cli.py: 351 passed.ruff checkandruff format --checkare clean on the changed Python files, andscripts/check_oss_boundary.pypassed.mainatd717f22cfis merged into the branch with no conflicts, andgit merge-treeagainst it is clean. Since this branch started,mainhas changedCHANGELOG.md,constants.py(fix(reporting): explain each dimension, its evidence and baseline in reports #376 and feat(plugin): recognize native OpenClaw manifests in the private plugin helpers #391, from line 635 on),docs/tier2-deduplication.mdx(feat(ci): add three-tier onboarding and private report feedback #349 and docs: simplify repository CI onboarding #443, a section near the top; fix(tier2): expose collection coverage and transactional rebuilds #436, the collection coverage text and a scale benchmark section) andtest_intra_skill_validator.py(fix(tier2): retain trailing shell comments in deduplication #357, one test near line 114) among the files this PR edits.🤖 Generated with Claude Code