一片一片 585abb979f
fix(gateway): reject unusable delegation state at the input boundary (#8375)
* fix(gateway): reject unusable delegation state at the input boundary

`delegations` is a caller-writable reducer channel. `merge_delegations`
keys on `id`/`run_id`/`dispatch_message_id` and indexes `status`, and the
ledger renderer indexes `description`/`subagent_type` on every model
call, so a non-list value, a non-object entry or a missing field fails
the state merge with an unhandled 500. On the thread-state route the bad
shape is persisted, so every later genuine ledger write keeps failing.

Validate the ledger shape at both caller-writable boundaries and keep
rejecting Overwrite markers and forged verdicts. The reducer also drops
stored values it cannot read, so a checkpoint written before this
validation self-heals instead of failing future writes.

* fix(harness): keep the ledger reducer tolerant of partial entries

The reducer only needs an identity key and a status; the renderer-only
text fields stay a boundary requirement. Dropping entries that lack
description/subagent_type would change reducer semantics for callers
that build minimal entries, so filter only what the reducer reads.

* test(gateway): use valid delegation in provenance check

---------

Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
2026-11-19 11:40:37 +08:00
..