polish(estimate_paragraph_for_page): closes #143 #145 #146 - #156
polish(estimate_paragraph_for_page): closes #143 #145 #146#156kiki830621 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
Verify — PR #156 (cluster: #143 #145 #146, plus a partial claim on #129)Verdict: FAIL — does not merge, and the conflict is not mechanical. The work itself is sound and still needed. The problem is what happened underneath it. 1. BLOCKING — the branch is built on a superseded implementationThe branch is 45 commits behind The reason matters more than the count: Concretely, resolving requires three judgment calls, not three text picks:
2. The three issues are all still live — the PR is still wantedChecked against current So v2 did not absorb any of this. Rebase, do not abandon. 3. The PR is self-consistent on its own baseRan on the branch as-is: Matching the description's claim. The failure above is integration, not implementation. 4. #129 is mis-scoped for this PRThe body says the
5. #146 is partially unmetDelivered: confidence ladder enumerated in the schema, Not delivered: #146's fourth bullet asks for calibration evidence — Either produce one measurement, or say plainly in #146 that this bullet is deferred — closing #146 on the other three bullets would quietly retire a request nobody declined. 6. Title will auto-close through the gate
Retitle to Suggested nextThen re-verify. The three conflicts each need a decision recorded, especially the |
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