Repository navigation
feat(processing): classify artifact processing failures with safe diagnostics (#2126) #2189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
guamiao
wants to merge
3
commits into
oceanbase:master
Choose a base branch
from
guamiao:fix/2126-processing-failures
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,424
−44
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| # Processing failure diagnostics | ||
|
|
||
| This page is the shared contract for classifying artifact-processing failures and for the safe | ||
| diagnostics attached to them. It extends the existing operational logging fields; it does not | ||
| introduce a second telemetry system. | ||
|
|
||
| ## Shared fields | ||
|
|
||
| Every processing failure keeps the existing identity and outcome fields (`family`, `operation`, | ||
| `worker_id`, `request_generation`, `outcome`, `error_code`, `exception_type`) and may add: | ||
|
|
||
| | Field | Meaning | Values | | ||
| |---|---|---| | ||
| | `processing_stage` | The stage that owned the failure | `generation`, `embedding`, `output_parsing`, `business_validation`, `persistence`, `usage_accounting` (reserved for usage reporting or persistence) | | ||
| | `failure_reason` | A bounded reason, only when evidence supports it | `context_overflow`, `output_truncated`, `rate_limit`, `timeout`, `schema_invalid`, `provider_unavailable`, `configuration`, `invalid_output`, `storage_failure`, `usage_limit` | | ||
| | `input_item_count` | Number of input items in the failing call | Non-negative integer | | ||
| | `estimated_input_tokens` | Estimated input tokens | Non-negative integer | | ||
| | `token_estimator_id` | Identity of the estimator that produced the estimate | Bounded string | | ||
| | `effective_budget` | Budget applied to the call | Non-negative integer | | ||
| | `provider_request_id` | Provider request identity, when reported | Bounded string | | ||
| | `finish_reason` | Provider finish reason, when reported | Bounded string | | ||
| | `failure_location` | Stable internal location or operation identifier | Bounded string | | ||
| | `cause_exception_type` | Original provider or library exception type before mapping | Bounded string | | ||
|
|
||
| `processing_stage` is distinct from the existing `stage` field. `stage` names the emitting boundary or | ||
| domain location: Worker and supervisor values (`worker_process`, `work_admission`, `supervisor`, | ||
| `lease_renewal`, `scope_discovery`, `pending_observation`, `term_revocation`, `worker_termination`), | ||
| domain block names such as `topic_memory`, and the child Worker's `worker` fallback when an exception | ||
| carries no stage. A child failure without a domain block may omit `stage` entirely. `processing_stage` | ||
| is the bounded domain stage. Counts and identifiers are bounded before they reach a log record, and | ||
| unknown or unsupported values are omitted rather than guessed. | ||
|
|
||
| ## Privacy boundary | ||
|
|
||
| Diagnostics never carry Source or Artifact bodies, prompts, model responses, credentials, | ||
| authorization headers, SQL parameters, or arbitrary exception text. Provider identifiers and reasons | ||
| are length-limited printable text. A field being allowlisted is not a redaction engine: values must | ||
| still be safe at the call site. | ||
|
|
||
| ## Coverage matrix | ||
|
|
||
| `Covered` means the stage has a stable classification and a test. `Partial` means some failures are | ||
| classified through the inferred operation or exception type but not every raise site is tagged. | ||
| `Missing` means the stage is not classified yet. `N/A` means the Family does not perform that stage | ||
| in its processing path. | ||
|
|
||
| | Family | Generation | Embedding | Output parsing | Business validation | Persistence | Usage accounting | | ||
| |---|---|---|---|---|---|---| | ||
| | Memory / Atomic Memory | Partial | Covered | Partial | Covered | Partial | Missing | | ||
| | Topic Memory | Partial | Partial | Partial | Missing | Missing | Missing | | ||
| | Experience | Partial | N/A | Partial | Missing | Missing | Missing | | ||
| | Profile | Partial | N/A | Partial | Missing | Missing | Missing | | ||
| | Skill | Partial | N/A | Partial | Missing | Missing | Missing | | ||
| | Handoff | Partial | N/A | Partial | Missing | Missing | Missing | | ||
| | Prompt | Partial | N/A | Partial | Missing | Missing | Missing | | ||
|
|
||
| Memory / Atomic Memory is tracked at operation granularity while it is the active slice: | ||
|
|
||
| | Operation | Stage | Status | Notes | | ||
| |---|---|---|---| | ||
| | `atomic-memory.extract` | Generation | Partial | Provider timeout, unavailability, rate limit, and configuration are classified; a provider finish reason is only visible where the adapter exposes it. | | ||
| | `atomic-memory.extract` | Output parsing | Partial | Schema and Pydantic output failures are classified; some provider truncation paths surface as schema failures. | | ||
| | `atomic-memory.extract` | Business validation | Covered | Candidate content and cited-evidence rules carry `business_validation` / `invalid_output`. | | ||
| | `atomic-memory.reconcile` | Generation | Partial | Same provider mapping as extraction. | | ||
| | `atomic-memory.reconcile` | Output parsing | Partial | Same schema mapping as extraction. | | ||
| | `atomic-memory.reconcile` | Business validation | Covered | Reconciliation output and content rules carry `business_validation` / `invalid_output`. | | ||
| | Embedding (extract, reconcile, query) | Embedding | Covered | Provider status, wrong vector count/order/type, and embedding profile/input failures are classified. | | ||
| | Publish / index | Persistence | Partial | `AtomicMemoryIndexError` codes are mapped; other storage failures keep unknown. | | ||
| | Usage accounting | Usage accounting | Missing | Usage-reporting and persistence failures are not classified; inference usage limits are reported in their originating stage (generation, or embedding when an adapter reports the limit). | | ||
|
|
||
| The first rollout slice covers Memory / Atomic Memory: provider failures, budget exhaustion, and | ||
| extraction/reconciliation validation are classified, and safe accounting fields travel from the | ||
| child Worker to the supervisor log. Other Families keep their current behavior until their own slice | ||
| lands; the matrix is updated in the same change as each slice. | ||
|
|
||
| ## Rollout | ||
|
|
||
| 1. Shared diagnostics contract, allowlisted fields, Worker propagation, and the Memory / Atomic | ||
| Memory slice (this change). | ||
| 2. Topic Memory: tag its staged generation, index/embedding, and persistence failures. | ||
| 3. Experience, Profile, and Skill: tag generation output validation and persistence entry points. | ||
| 4. Handoff and Prompt: tag generation and publication failures, then add usage-accounting | ||
| classification and complete the matrix. | ||
|
|
||
| For new instrumentation, cover the observable behavior: successful classification, propagation | ||
| across a real spawned Worker, sensitive-value exclusion, and that a diagnostics failure does not | ||
| change the business outcome. |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # 处理失败诊断 | ||
|
|
||
| 本文是 Artifact 处理失败分类与安全诊断的共享契约。它扩展现有的可观测性日志字段,不引入第二套 | ||
| telemetry 系统。 | ||
|
|
||
| ## 共享字段 | ||
|
|
||
| 每次处理失败保留现有的身份与结果字段(`family`、`operation`、`worker_id`、`request_generation`、 | ||
| `outcome`、`error_code`、`exception_type`),并可按需增加: | ||
|
|
||
| | 字段 | 含义 | 取值 | | ||
| |---|---|---| | ||
| | `processing_stage` | 失败所属的处理阶段 | `generation`、`embedding`、`output_parsing`、`business_validation`、`persistence`、`usage_accounting`(预留给账务上报或持久化) | | ||
| | `failure_reason` | 有证据支持时才给出的有界原因 | `context_overflow`、`output_truncated`、`rate_limit`、`timeout`、`schema_invalid`、`provider_unavailable`、`configuration`、`invalid_output`、`storage_failure`、`usage_limit` | | ||
| | `input_item_count` | 失败调用涉及的输入条目数 | 非负整数 | | ||
| | `estimated_input_tokens` | 估算的输入 token 数 | 非负整数 | | ||
| | `token_estimator_id` | 产生估算值的估算器标识 | 有界字符串 | | ||
| | `effective_budget` | 本次调用生效的预算 | 非负整数 | | ||
| | `provider_request_id` | provider 返回的请求标识 | 有界字符串 | | ||
| | `finish_reason` | provider 返回的结束原因 | 有界字符串 | | ||
| | `failure_location` | 稳定的内部位置或操作标识 | 有界字符串 | | ||
| | `cause_exception_type` | 映射前的原始 provider/库异常类型 | 有界字符串 | | ||
|
|
||
| `processing_stage` 与既有的 `stage` 字段不同:`stage` 表示发出失败的位置或领域位置,包括 | ||
| Worker/supervisor 值(`worker_process`、`work_admission`、`supervisor`、`lease_renewal`、`scope_discovery`、 | ||
| `pending_observation`、`term_revocation`、`worker_termination`)、领域 block 名称(如 `topic_memory`), | ||
| 以及异常未携带 stage 时 child Worker 的 `worker` 兜底;没有领域 block 的 child 失败可能完全省略 `stage`。 | ||
| `processing_stage` 表示有界的领域阶段。计数与标识在写入日志前会被限界;未知或不受支持的值直接省略, | ||
| 不做猜测。 | ||
|
|
||
| ## 隐私边界 | ||
|
|
||
| 诊断不得包含 Source/Artifact 正文、prompt、模型响应、凭据、授权头、SQL 参数或任意异常文本。provider | ||
| 标识与原因只保留有长度上限的可打印文本。字段进入白名单不等于自动脱敏,调用点仍必须保证值本身安全。 | ||
|
|
||
| ## 覆盖矩阵 | ||
|
|
||
| `Covered` 表示该阶段已有稳定分类与测试;`Partial` 表示部分失败可经 operation 或异常类型推断,但尚未覆盖 | ||
| 所有抛出点;`Missing` 表示尚未分类;`N/A` 表示该 Family 的处理路径不执行该阶段。 | ||
|
|
||
| | Family | Generation | Embedding | Output parsing | Business validation | Persistence | Usage accounting | | ||
| |---|---|---|---|---|---|---| | ||
| | Memory / Atomic Memory | Partial | Covered | Partial | Covered | Partial | Missing | | ||
| | Topic Memory | Partial | Partial | Partial | Missing | Missing | Missing | | ||
| | Experience | Partial | N/A | Partial | Missing | Missing | Missing | | ||
| | Profile | Partial | N/A | Partial | Missing | Missing | Missing | | ||
| | Skill | Partial | N/A | Partial | Missing | Missing | Missing | | ||
| | Handoff | Partial | N/A | Partial | Missing | Missing | Missing | | ||
| | Prompt | Partial | N/A | Partial | Missing | Missing | Missing | | ||
|
|
||
| Memory / Atomic Memory 作为当前切片,按 operation 粒度跟踪: | ||
|
|
||
| | Operation | Stage | 状态 | 说明 | | ||
| |---|---|---|---| | ||
| | `atomic-memory.extract` | Generation | Partial | provider timeout、不可用、限流、配置错误已分类;仅 adapter 暴露 finish reason 时可见。 | | ||
| | `atomic-memory.extract` | Output parsing | Partial | schema 与 Pydantic 输出失败已分类;部分 provider 截断仍表现为 schema 失败。 | | ||
| | `atomic-memory.extract` | Business validation | Covered | 候选内容与引用证据规则输出 `business_validation` / `invalid_output`。 | | ||
| | `atomic-memory.reconcile` | Generation | Partial | 与提取相同的 provider 映射。 | | ||
| | `atomic-memory.reconcile` | Output parsing | Partial | 与提取相同的 schema 映射。 | | ||
| | `atomic-memory.reconcile` | Business validation | Covered | 对账输出与内容规则输出 `business_validation` / `invalid_output`。 | | ||
| | Embedding(提取、对账、查询) | Embedding | Covered | provider 状态、向量数量/顺序/类型错误、profile/input 失败均已分类。 | | ||
| | Publish / index | Persistence | Partial | `AtomicMemoryIndexError` 的 code 已映射;其他存储失败保持 unknown。 | | ||
| | Usage accounting | Usage accounting | Missing | 尚未分类账务上报与持久化失败;推理用量限制归入其来源阶段(generation,或 embedding adapter 上报时归入 embedding)。 | | ||
|
|
||
| 第一个落地切片覆盖 Memory / Atomic Memory:provider 失败、预算耗尽、提取/对账校验均有分类,安全计数字段 | ||
| 可从子 Worker 传播到 supervisor 日志。其他 Family 在各自切片落地前保持现有行为;每次切片在同一变更中更新 | ||
| 本矩阵。 | ||
|
|
||
| ## 落地顺序 | ||
|
|
||
| 1. 共享诊断契约、日志白名单字段、Worker 传播,以及 Memory / Atomic Memory 切片(本次变更)。 | ||
| 2. Topic Memory:标注分阶段生成、索引/嵌入与持久化失败。 | ||
| 3. Experience、Profile、Skill:标注生成输出校验与持久化入口。 | ||
| 4. Handoff、Prompt:标注生成与发布失败,再补 usage accounting 分类并补全矩阵。 | ||
|
|
||
| 新增 instrumentation 时,需要覆盖可观察行为:分类正确、跨真实 spawn Worker 传播、敏感值不出现,以及诊断 | ||
| 失败不改变业务结果。 |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] This branch no longer merges into
mastermasterhas moved past the PR base. The merge-base isc0c38dea,masteris now0bc42d0b(13 commits, including #2139 which rewrote input handling in this very function).git merge-tree --write-tree master refs/pr/2189reports exactly one content conflict, and it is in this hunk: the newtry:/except ValidationErrorwrapper aroundAtomicMemoryExtractionOutput.model_validate. GitHub agrees withmergeable: false/mergeable_state: dirty, so the PR cannot merge as submitted.Two facts to fold into the rebase:
descriptionthroughAtomicMemoryCandidate/AtomicMemoryContent. Whichever PR lands second must re-resolve this hunk, and the PR body's testing section should record how that reconciliation was verified.Scope note: this is a branch-sync blocker, not a defect in the change. I re-ran the PR's own selection on the unmodified head (
61df175a, Python 3.14.3):tests/builtin/test_processing_diagnostics.py tests/builtin/inference/test_pydantic_ai.py tests/builtin/inference/test_minimax_embedding.py tests/builtin/artifacts/atomic_memory tests/builtin/artifacts/memory tests/builtin/runtime/test_artifact_processing.py tests/e2e/test_worker_logging.py-> 213 passed, 5 skipped.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebased onto 0bc42d0. The only conflict was the import block in
atomic_memory/extraction.py; the try/except wrapper still coversmodel_validateandAtomicMemoryContent.git merge-tree --write-tree upstream/master HEADexits 0 locally, a range-diff against the pre-rebase head preserved both commits, and the PR description records the #2192 overlap on the same hunk. Tests on the rebased tree: 276 passed, 5 skipped.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@guamiao, GitHub currently reports merge conflicts with
master(mergeable_state: dirty). Please update this branch against the latestmasterand resolve the conflicts, preserving the latest master changes and the new diagnostics. Then rerun the Memory/Atomic Memory, inference, and worker logging tests, and update the PR with the validation results.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conflict resolutions (
70f6aa7e):inference/pydantic_ai.py: kept master's_checked_rulehelper and the bounded_map_errornoqa.runtime/artifact_processing.py: kept master'sprocessing_error_code(type, error_code)call and re-applied the diagnostics classification.runtime/atomic_memory_processing.py: merged master's newSOURCES_TABLEimport with the diagnostics imports.tests/builtin/inference/test_pydantic_ai.py: kept master's expanded imports and addedUsageLimitExceeded/_map_error.atomic_memory/extraction.pymerged without a conflict on this head; thetry/except ValidationErrorwrappers aroundAtomicMemoryExtractionOutput.model_validateandAtomicMemoryContentremain intact on top of the current body. #2192 is still open; if it lands first, this block will need the same re-resolution noted earlier.Validation on
70f6aa7e(Python 3.14.3):pytest tests/builtin/test_processing_diagnostics.py tests/builtin/inference tests/builtin/artifacts/atomic_memory tests/builtin/artifacts/memory tests/builtin/runtime/test_artifact_processing.py tests/e2e/test_worker_logging.py -q→ 272 passed, 5 skippedruff check,ruff format --check,ty checkon the changed files → cleangit diff --check upstream/master..HEAD→ cleanmergeable: true.The stacked Topic Memory branch was rebased onto this head (
f7a06284); its suite is 555 passed, 5 skipped.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
复核新 head
70f6aa7e:mergeable=MERGEABLE,rebase 后与master无冲突,本线程的 P1 已解除。独立验证(exact head 树 + 隔离PYTHONPATH):tests/builtin/test_processing_diagnostics.py与tests/builtin/inference/test_minimax_embedding.py50 passed、tests/builtin/inference/test_pydantic_ai.py39 passed;extraction.py的try/except ValidationError包裹在 rebase 后仍覆盖model_validate。按已修复记录,不再重复提出。