Skip to content

spec-sync(v2): parse: add confidence to word-level atomic grounding - #145

Merged
tian-lan-landing merged 3 commits into
mainfrom
spec-sync/v2
Aug 17, 2026
Merged

spec-sync(v2): parse: add confidence to word-level atomic grounding#145
tian-lan-landing merged 3 commits into
mainfrom
spec-sync/v2

Conversation

@yzld2002

@yzld2002 yzld2002 commented Aug 17, 2026

Copy link
Copy Markdown
Member

Automated V2 spec-sync PR (client.v2).

  • Commit 1 (mechanical): normalized V2 spec snapshot + regenerated reference models.
  • Commit 2 (AI, only if the spec diff needs SDK changes): client.v2 resources/methods/tests/docs wired from the diff, added after this PR opened. Workflow-only drift is excluded and an AI no-op is skipped, so some drifts produce a mechanical-only PR with no second commit.

Gates (surface-lock, V2 contract tests, lint/test/typecheck) must pass. When present, the AI commit is a draft a human finishes (the V2 ergonomic layer — unified Job, dual-host, schema coercion — is not in the spec). Human review required before merge.

What changed

AI-generated from the PR diff — verify against the actual changes.

This PR adds a confidence field to word-granularity atomic grounding segments in parse responses; the spec snapshot also gains new /v1/extract* routes but those are not wired into the client surface.

Changes:

  • Added optional confidence field to V2ParseNodeGrounding, populated only on word-granularity (dpt-3-fast) atomic_grounding entries.
  • Updated documentation for atomic_grounding to clarify granularity varies by model (line-level for dpt-3-pro, word-level for dpt-3-fast) and to describe the new confidence semantics, including the empty-list cases for table cells.
  • Clarified that table-cell atomic_grounding may be [] when word offsets can't be reliably located in escaped pipe/HTML table text.
  • Spec snapshot gained new /v1/extract, /v1/extract/build-schema, and related job-polling routes plus V1ExtractMetadata/V1BuildSchemaMetadata models, but these are not exposed through the SDK client.

Copilot AI balanced review requested due to automatic review settings August 17, 2026 07:20
@yzld2002
yzld2002 deployed to spec-sync-contract August 17, 2026 07:20 — with GitHub Actions Active

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates the mirrored V2 OpenAPI snapshot and regenerated reference models to track upstream drift.

Changes:

  • Refreshes the V2 specification snapshot.
  • Regenerates reference Pydantic models from the updated specification.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
specs/v2-aide.json Updates the mirrored upstream specification.
specs/_generated/v2_models.py Regenerates reference models from the snapshot.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings August 17, 2026 07:26
@yzld2002
yzld2002 deployed to spec-sync-contract August 17, 2026 07:26 — with GitHub Actions Active
@yzld2002 yzld2002 changed the title spec-sync: track V2 spec drift spec-sync(v2): parse: add confidence to word-level atomic grounding Aug 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

Suppressed comments (1)

tests/contract/test_v2_smoke.py:104

  • This live test can pass without exercising the new field: it does not select dpt-3-fast, and it never requires an atomic segment or a non-None confidence. A default line-granularity response—or a regression that drops all confidence values—therefore leaves the test green. Request the word-granularity model and require at least one segment plus a valid confidence on every returned segment.
    resp = staging_client.v2.parse(document=pdf, options={"atomic_grounding": True})

…sses

The AI commit annotated `_walk`'s parameter as `object` and silenced the
resulting attribute access with a `type: ignore`, which left every value
inside the loop untyped -- 6 `reportUnknown*` errors under the repo's
strict pyright config, failing CI lint.

Annotate the recursion properly with `List[V2ParseElement]` and move the
None-coalescing to the call site. No behavior change.

Co-Authored-By: Claude Opus 5 <[email protected]>
Copilot AI review requested due to automatic review settings August 17, 2026 08:46
@tian-lan-landing
tian-lan-landing deployed to spec-sync-contract August 17, 2026 08:46 — with GitHub Actions Active

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

Suppressed comments (2)

tests/contract/test_v2_smoke.py:105

  • This contract test can pass without exercising the new wire field: it neither selects dpt-3-fast nor requires any atomic segment or confidence value to exist. A line-granularity response, an empty atomic_grounding, or a client that drops confidence all satisfy the current assertions. Request the word-granularity model and require at least one bounded confidence value so the staging contract is actually verified.
def test_parse_atomic_grounding_confidence(staging_client: LandingAIADE) -> None:
    # `atomic_grounding` segments carry an optional per-segment `confidence` in
    # [0, 1] on word-granularity models (`dpt-3-fast`); line-granularity models
    # omit it. Tolerate either: assert every present value is a valid probability.
    pdf = Path(__file__).parent / "sample.pdf"
    resp = staging_client.v2.parse(document=pdf, options={"atomic_grounding": True})

docs/v2-testing.md:47

  • The PR description says the table-cell empty-list cases are documented, but this guide only explains when the field is omitted. Consumers still cannot tell that [] is expected for table cells on line-granularity models or when escaped pipe/HTML rendering prevents reliable word offsets. Add those cases here (and the suppressed-Markdown case) to keep the reviewable SDK documentation aligned with the stated behavior.
    Each segment reuses the node-grounding shape (`page`, `range`, `box`) and, on
    word-granularity models only, an optional `confidence` in `[0, 1]` (the
    lowest per-character OCR confidence in the word; `None` on line-granularity
    models and on node-level grounding). Omitted when `options.atomic_grounding`
    is `false`.

@tian-lan-landing
tian-lan-landing merged commit ce4ace0 into main Aug 17, 2026
6 checks passed
tian-lan-landing added a commit that referenced this pull request Aug 17, 2026
The V2 AI wiring step runs with no shell (deliberately -- it holds the
checkout's push credentials and the fetched spec is untrusted input), so
nothing type-checked its output: the step after it only formats. Every
mistake pyright can see therefore landed as a red `lint` job on a PR that
otherwise looked review-ready.

- Run `./scripts/lint` in the existing trusted step and hand its output to
  a second shell-less Claude pass that fixes what it reports, then re-apply
  the product-code allowlist and re-lint. Closes the loop without granting
  a shell. The repair prompt forbids silencing (`# type: ignore`, widening
  to `object`/`Any`, deleting the failing assertion) so it fixes causes.
  The Slack reply now says whether lint ended clean, self-repaired, or is
  still failing, instead of implying the wiring is clean.
- Two wiring-prompt rules for what the AI actually got wrong on #145/#110:
  read optionality from the schema's `required` array rather than the
  description prose (and treat absent and null alike), and never pin
  `model=` in a live contract test or assert an optional field is
  populated -- value assertions belong in the mocked tests.
- Contract smoke tests: cap a request at 45s with no retries instead of the
  SDK's 8-minute/2-retry default, so a dead upstream fails in 45s naming
  the route rather than burning the gate.

Co-Authored-By: Claude Opus 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.

3 participants