Skip to content

Name the bundle template in a failed C API 1.0 LiteRT-LM chat send - #1875

Closed
leehack wants to merge 2 commits into
mainfrom
fix/1868-v1-send-note
Closed

leehack wants to merge 2 commits into
mainfrom
fix/1868-v1-send-note

Conversation

@leehack

@leehack leehack commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • A failed native LiteRT-LM chat send on the C API 1.0 runtime now gets the bundle-template / ModelParams.chatTemplate note, as the legacy runtime already did. _generateChat caught only StateError.
  • The note is added by where the failure is thrown, not by message text: the v1 conversation marks a failed send call (conversation_send_message_stream, where template failures surface) as LiteRtLmSendFailureException (a LlamaModelException), and only that type gets the note, keeping its type and details. Failures the stream reports later (C API 1.0 stream failed, such as a context overflow) and LiteRtLmV1CopyLossException pass through unchanged, as do other LlamaExceptions.

Fixes #1868. Refs #1874.

Production-readiness scope

  • User-facing scope: the explanatory note on a failed chat send on the default (C API 1.0) native runtime. Diagnostic only; the request fails with the native error either way.
  • Supported platforms/paths: native LiteRT-LM, both clients.
  • Unsupported or intentionally unavailable paths: N/A.
  • Out of scope / follow-ups: None.

Completeness checklist

  • Declared scope is fully implemented.
  • Unsupported platform/option combinations: N/A, no change.
  • Changelog updated (both files); no public API or docs change.
  • Regression coverage: legacy and v1 fakes throw what each client throws, for both notes; a v1 stream failure (context-overflow shape) gets no note, with and without a custom template; details preserved; another LlamaException unchanged; v1 conversation tests assert the send-call failure type and that stream failures are not marked.
  • Validation registry: N/A, no capability change.
  • Security/privacy: no new data in messages; the note text is unchanged.
  • Follow-ups: None.

PR type guidance

  • Bugfix PR: root cause above; tests in litert_lm_service_test.dart; native platforms only.

Test Plan

  • dart run tool/prepare_workspace.dart
  • dart format --output=none --set-exit-if-changed .
  • dart analyze
  • dart test -p vm -j 1 --exclude-tags local-only (CI)
  • dart test -p chrome --exclude-tags local-only (CI)
  • coverage-lib N/A: the new branch is covered by the unit tests above; main enforces the threshold.
  • TMPDIR=$(mktemp -d) dart test -p vm -j 1 test/unit/backends/litert_lm/litert_lm_service_test.dart

Mutations (each fails the tests): retyping the v1 note as StateError; catching any LlamaModelException (note on stream failures); dropping details; retyping to plain LlamaModelException; not marking the send failure in the v1 conversation; dropping the catch.

Matrix Evidence

Matrix row Scope covered Platform / model / backend Result Evidence / notes
static-format-analyze format, analyze macOS PASS local
root-vm litert_lm service unit tests macOS VM PASS test/unit/backends/litert_lm 1542 tests
high-risk-exact-head-independent-qa exact-head audit - PENDING classified high-risk (backendRuntime); draft until audited

Review Notes

  • Independent review status: audit of df7cf70e2 passed with 3 findings, fixed in 03d50e48e.
  • CI status / head SHA: pending.

High-risk regression review

  • Classification: high-risk (backendRuntime, from classify_high_risk_changes.dart; the change is a diagnostic-only catch clause)
  • Implementation task: this PR
  • Independent blocking QA task: pending

Independent audit

Exact head 03d50e48e8f9c40bf1bb56f0116513049a8a26d7 against main f78cafa97: PASS (delta re-audit after the first pass), 0 blocking, 0 PR-caused P1, 0 threads. Real model (Qwen3-0.6B.litertlm, CPU): a custom template failing at send keeps the note; context overflow gets no note; cancel and normal requests unchanged. 11/12 mutants killed (survivor is unobservable today). Readiness evidence v2: local run exits 2. Non-blocking items tracked on #1861.

LiteRtLmService._generateChat added the bundle-template note only to the
legacy client's StateError. The C API 1.0 client reports a failed send as
LlamaModelException, so it lost the note. Route it through the same path,
keeping its exception type.

Refs #1868, #1874
…ures

The note went to every LlamaModelException before output, so a context
overflow reported later by the stream ("C API 1.0 stream failed") got it
too. The v1 conversation now marks a failed send call with
LiteRtLmSendFailureException and only that type gets the note; stream
failures and LiteRtLmV1CopyLossException pass through unchanged.

Refs #1868, #1874
@leehack
leehack marked this pull request as ready for review November 10, 2026 02:05
@github-actions

Copy link
Copy Markdown
Contributor

@leehack

leehack commented Nov 10, 2026

Copy link
Copy Markdown
Owner Author

Landed on main via batch integration PR #1895 (rebase merge, main ba4e0e1b; tree identical to the audited integration head 5ffd1224).

@leehack leehack closed this Nov 10, 2026
@leehack
leehack deleted the fix/1868-v1-send-note branch November 10, 2026 13:16
@leehack leehack mentioned this pull request Nov 22, 2026
13 tasks done
leehack added a commit that referenced this pull request Nov 22, 2026
## Summary

- Sweep orphaned `leehack/llamadart-chat-pr-<N>` Spaces daily or by
manual dispatch on `main`. Each deletion shares the preview write queue
and rechecks the live PR state before calling Hugging Face.
- PRs #1875, #1876, and #1882 closed at 12:52:17, 12:52:21, and 12:52:34
UTC on November 10, 2026, after integration #1895 merged at 12:52:07 UTC
(`ba4e0e1b`). The prior investigation found merge conflicts with that
integration commit and no close-time Actions runs for those branches.
GitHub suppresses `pull_request` workflows when the PR has merge
conflicts. [GitHub Actions event
documentation](https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#pull_request)
- The older #218 orphan reached deletion and failed. Its expired log
leaves the cause unknown.

Closes #2160

## Changelog

N/A: CI-only housekeeping.

## Production-readiness scope

- **User-facing scope:** Closed PR preview Spaces are reclaimed when
event-driven cleanup misses them.
- **Supported platforms/paths:** Scheduled and manual GitHub Actions
runs on `leehack/llamadart` main, using `HF_TOKEN` and read-only GitHub
PR lookups.
- **Unsupported or intentionally unavailable paths:** Production and
other Space IDs are outside the sweep. Missing and open PRs are skipped.
A missing preview Space is treated as already removed.
- **Out of scope / follow-ups:** None.

## Completeness checklist

- [x] Declared scope is implemented.
- [x] Unsupported paths are documented.
- [x] Maintainer instructions are updated. Public API, examples, support
matrix, and changelogs are N/A for this CI change.
- [x] Regression tests distinguish closed, open, missing, and reopened
PRs and reject out-of-scope Space IDs.
- [x] Public capability validation registry is N/A for this CI change.
- [x] Mocked provider failures verify redaction of raw response text,
tokens, and signed URLs.
- [x] Follow-up work is listed above.

## PR type guidance

- **Bugfix PR:** The trigger gap and delete-failure evidence are in the
summary. GitHub Actions workflow and offline provider coverage are in
the matrix.
- **Feature and docs-only guidance:** N/A for a CI bugfix with
maintainer documentation.

## Test Plan

- [x] `dart run tool/prepare_workspace.dart` on the clean worktree.
- [x] `python3 tool/ci/check_format.py`, `dart analyze`, and `dart run
tool/testing/check_platform_boundaries.dart`.
- [x] Targeted VM tooling tests with isolated `TMPDIR` passed 116 tests,
including the Markdown reader inventory.
- [x] `python3 -B -m unittest discover -s test/ci -p 'test_*.py'` ran
274 tests with 34 skips. The final preview suite ran 20 tests.
- [x] Actionlint 1.7.12 passed with the repository's exact
`concurrency.queue` suppression. Unfiltered output reported the known
queue diagnostic.
- [x] Failing-first controls reproduced missing sweep wiring. Removing
the queue caused the workflow test to fail. Removing the recheck caused
the reopened-PR test to observe a mock deletion.
- The initial full VM tooling run found one Markdown reader inventory
mismatch. The final targeted rerun verified the exemption update and
preview tests.
- **Full root VM and Chrome suites:** N/A to the workflow execution
path. Targeted tooling tests cover job wiring and both provider call
paths.
- **`coverage-lib`:** N/A for a CI-only change.
- **Live Hugging Face execution:** Mocked by assignment. No live
listing, creation, deletion, or workflow dispatch.

## Matrix Evidence

| Matrix row | Scope covered | Platform / model / backend | Result |
Evidence / notes |
| --- | --- | --- | --- | --- |
| `ci-selection` | PR event gates, empty matrix, shared write group,
read-only GitHub permissions, and unchanged close workflow | macOS, Dart
VM and Python, mocked provider | PASS |
`ci_workflow_selection_test.dart`, `preview_guard_test.dart`,
`hf_space_deploy_test.dart`, and `markdown_test_suites_test.dart` passed
116 tests. |
| `static-format-analyze` | Dart format, analysis, and web/native import
boundaries | macOS, pinned Flutter 3.47.1 | PASS | Repository format
helper, analyzer and boundary checker passed. |
| Sweep regression checks | Exact IDs, closed/open/missing/reopened PRs,
404, redaction, and empty output | macOS, Python, mocked provider | PASS
| `test/ci/test_preview_sweep.py`; both mutation controls failed as
expected. |
| `high-risk-exact-head-independent-qa` | Independent review against
current main | GitHub Actions and mocked provider | PASS | Fresh-session
`auditor-deep` ACCEPT at `eb328e0c`. A reopened PR, an unknown PR state
and an out-of-scope id each caused zero deletions, and all 3 mutations
were caught. Readiness exits 2 locally |

## Review Notes

- **Independent review status:** ACCEPT. One nonblocking P3: a backlog
over 256 closed previews exceeds GitHub's 256-job matrix cap. Today's
backlog is 0, and the P3 is tracked in #2098.
- **CI status / head SHA:** 36 passed, 9 skipped on
`eb328e0c133bb643e34208b3167502534e9fa685`.

## High-risk regression review

- **Classification:** High-risk (`regressionPolicy`).
- **Implementation task:** #2160 preview sweep implementation.
- **Independent blocking QA task:** Fresh-session `auditor-deep` audit,
ACCEPT
- **Exact head / current base:**
`eb328e0c133bb643e34208b3167502534e9fa685` /
`d38c50377b17e06d0cd1a90265a93d7963ccc030`.
- **Production-branch deletion, bypass, or miswire proof:** Removing the
concurrency block failed the YAML wiring test. Removing the shared
callback invocation caused `delete_repo` to be called for a reopened PR.
- **Affected-family real-model/artifact evidence:** N/A for the GitHub
Actions policy change.
- **Explicit unavailable-family or other N/A evidence:** Hugging Face
operations were mocked under the task's live-operation restriction.
- **Known PR-caused P1 regressions:** 0. The independent audit agrees.
- **Unresolved review threads:** 0 at creation.
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.

LiteRT-LM C API 1.0 chat send failures miss the bundle template note

1 participant