polish(estimate_paragraph_for_page): closes #143 #145 #146 - #156
Open
kiki830621 wants to merge 1 commit into
Open
polish(estimate_paragraph_for_page): closes #143 #145 #146#156kiki830621 wants to merge 1 commit into
kiki830621 wants to merge 1 commit into
Conversation
Bundle C from PR #114 6-AI verify follow-up. Three orthogonal polish items in a single tool, single code path: #143 (P2) — Confidence label calibration Pre-fix: caller-supplied chars_per_page DOWNGRADED confidence to "low" because layoutBasis switched to "caller_chars_per_page" and the medium predicate required "section_properties". Inverted semantics — caller calibration is ground truth, not heuristic noise. Post-fix ladder (confidence + new confidence_reason field): high / caller_provided_chars_per_page — caller calibration trusted medium / default_heuristic_long_doc — paragraph_count >= 10 low / default_heuristic_short_doc — short docs low / page_beyond_estimated_document — out-of-range page low / empty_document — 0 paragraphs Threshold tightened from 3 to 10 paragraphs for medium per verify P2 (3-paragraph docs are below per-paragraph noise floor). #145 (P3) — Error format unification Three calibration errors previously returned plain-text "Error: estimate_paragraph_for_page: ..." while WordError went through MCP runtime as structured. Caller parser had to fork. Post-fix: all 3 invalid-parameter paths return structured JSON via new estimateValidationError helper: { "error": "invalid_parameter", "tool": "estimate_paragraph_for_page", "field": "page" | "chars_per_page" | "context_paragraphs", "reason": "must be 1..100000" | ..., "received": <int> } empty_document path also normalized: now returns method / layout_basis / confidence / confidence_reason fields so callers can parse uniformly without branching on error key first. echo received value also satisfies #129 within this tool's scope. #146 (P3) — Schema description polish Schema description now enumerates the confidence ladder, documents the default chars_per_page derivation formula (charsPerLine * linesPerPage, ≈1189 for A4 / ≈1134 for Letter / 3000-3500 for English IEEE), and lists the JSON error format. Per-arg descriptions added clamp ranges (page 1..100000, chars_per_page 1..200000, context_paragraphs 0..1024). Tests: 7 → 12 in Issue89EstimateParagraphForPageTests - existing 7 updated to assert structured JSON instead of plain-text Error: - testCallerProvidedCharsPerPageGivesHighConfidence (P0 for #143 fix) - testLongDocumentDefaultHeuristicGivesMediumConfidence - testShortDocumentDefaultHeuristicGivesLowConfidence - testBeyondDocumentRequestKeepsLowConfidence - testEmptyDocumentReturnsStructuredErrorWithFullSchema (#145) Full suite: 266 → 271, 0 failures, 9 pre-existing skips. Refs #143 #145 #146
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bundle C from PR #114 6-AI verify follow-up. Three orthogonal polish items in a single tool / code path:
#143 (P2) — Confidence label calibration
Pre-fix: caller-supplied
chars_per_pagedowngraded confidence to"low"(semantic inversion — caller calibration is ground truth, not heuristic noise).Post-fix ladder (
confidence+ newconfidence_reasonfield):caller_provided_chars_per_pagedefault_heuristic_long_docdefault_heuristic_short_docpage_beyond_estimated_documentempty_documentThreshold tightened from 3 → 10 paragraphs (3-paragraph docs are below per-paragraph noise floor).
#145 (P3) — Error format unification
Three
invalid_parameterpaths now return structured JSON via newestimateValidationErrorhelper:{ "error": "invalid_parameter", "tool": "estimate_paragraph_for_page", "field": "page" | "chars_per_page" | "context_paragraphs", "reason": "must be 1..100000" | ..., "received": <int> }empty_documentpath also normalized — now returnsmethod/layout_basis/confidence/confidence_reasonso callers parse uniformly without branching onerrorkey first.receivedecho also satisfies #129 within this tool's scope.#146 (P3) — Schema description polish
chars_per_pagederivation formula documented (≈1189 for A4 / ≈1134 for Letter / 3000-3500 for English IEEE)Tests
7 → 12 in
Issue89EstimateParagraphForPageTests:Error:testCallerProvidedCharsPerPageGivesHighConfidence(P0 for estimate_paragraph_for_page: confidence label inflation + caller-calibrated semantic inversion #143 fix)testLongDocumentDefaultHeuristicGivesMediumConfidencetestShortDocumentDefaultHeuristicGivesLowConfidencetestBeyondDocumentRequestKeepsLowConfidencetestEmptyDocumentReturnsStructuredErrorWithFullSchema(estimate_paragraph_for_page: unify error format + document empty_document schema branch #145)Full suite: 266 → 271, 0 failures, 9 pre-existing skips.
Backward compat
Breaking schema change for callers parsing the plain-text
Error: estimate_paragraph_for_page: ...strings — they now get JSON.estimate_paragraph_for_pagewas added in #114 (just merged), so this is essentially shipping the corrected v1 contract before any external caller adopts the v0 plain-text format.Existing valid callers (page within range, chars_per_page provided as positive int, etc.) get the same response shape with one additive new field (
confidence_reason).Refs #143 #145 #146