regen: sync SDK with corrected monit + a2a specs#31
Merged
Conversation
Regenerated from flashduty-docs after the monit contract sync and the a2a
tag repair (flashduty-docs PR #190).
What changes for consumers:
ToolInvokeResponseResultsItem gains Summary, Params and Truncated.
These have been missing since the type was first generated, so
`fduty monit-agent invoke` silently dropped the per-tool summary on
every successful call — the field simply had nowhere to decode into.
Verified against the live dev API: rebuilding the CLI on this SDK turns
[agent_elapsed_ms data e2e_elapsed_ms error tool tool_version]
into
[agent_elapsed_ms data e2e_elapsed_ms error params summary tool
tool_version truncated]
with a real summary line ("os.overview cpu=30.69% mem=74.53% ...").
Diagnose evidence types now come from the docs spec rather than a
hand-edited vendored copy, so `make sync-spec` no longer erases them.
New services Licenses and SessionReplay appear because the docs spec has
moved on since this branch last synced. No service is lost — the
generated service set is a strict superset of the previous one.
Note on `en.go`: regenerating against the *unfixed* docs spec produced a
bogus `EnService` and dropped `A2aAgents` entirely, because seven
/safari/a2a-agent/* operations carried a bare "en"/"zh" tag instead of
"AI SRE/A2A agents". That is fixed on the docs side in the same PR; the
stale generated file is removed here.
Still outstanding: response structs decode absent optional objects into
zero values, so the CLI re-serializes `error:{"code":"","message":""}` and
`truncated:{"reason":""}` even though the API omits both. That needs a
generator change (optional nested structs in response types should emit as
pointers with omitempty) and is deliberately not bundled into this regen.
…ving spec
Picks up flashduty-docs' x-flashduty-preserve-absence markers on the sparse
tool-invoke / tool-catalog response fields. The generator already honours the
extension (internal/cmd/gen/main.go), so this is a pure spec-driven regen:
10 fields move from value types to *T + omitempty, matching monit-webapi's
omit-when-empty wire contract.
Closes the second half of the monit contract drift: consumers no longer
materialise a fabricated error:{"code":"","message":""} / truncated:{"reason":""}
on successful calls. params, tool, and the two elapsed counters stay value
types — webapi always emits them.
Spec-driven regen from flashduty-docs. `ToolInvokeResponseError.TargetKinds`
and `ToolCatalogResponseError.TargetKinds` become `*[]string` + omitempty,
matching webapi's `json:"target_kinds,omitempty"`.
Verified on live dev: a CLI built from this SDK now returns a bare
{"error":{"code","message"},"tools":[]} on the target_unavailable path,
byte-shape-identical to the webapi response. Previously it appended
"target_kinds": null.
Example-only change; models_gen.go is byte-identical. TestSpecExamplesRoundTrip green against the live-captured failure entry.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
依赖 flashduty-docs #190(先合那个,再合这个)。
为什么
monit-webapi
d0d1ef4(2026-07-20 15:53)把 tools/invoke 改成稀疏字段并拍平了单工具结果。生成的ToolInvokeResponseResultsItem从来就没有Summary/Params/Truncated字段——摘要根本没有地方可以解码进去,所以fduty monit-agent invoke在每一次成功调用上都静默把它丢掉。用 v1.3.26(嵌进 runner、发到全部沙箱与 BYOC 的那个版本)从 tag 编译后实测确认,缺陷此刻活在整个 fleet 上。
本 PR 是什么
三个提交,都是纯重新生成(
make sync-spec+make generate),spec 来自 docs #190。端到端验证——基于本分支重建 flashduty-cli 后打真实 dev API:
找回的摘要:
os.overview cpu=33.50% mem=74.47% swap=not_configured oom_kill_since_boot=2 load1=3.84。成功时不再出现error/truncated键——输出与 webapi 裸线形态逐键一致。其他变化:
make sync-spec不会再把它抹掉Licenses、SessionReplay:docs spec 自本分支上次同步(07-14)以来的新接口。没有任何服务丢失,生成的服务集是原来的严格超集关于被删掉的
en.go对未修复的 docs spec 生成会产出一个假的
EnService并彻底丢失A2aAgents,因为 7 个/safari/a2a-agent/*操作的 tag 是裸的"en"/"zh"而非"AI SRE/A2A agents"。docs #190 已修复该问题,这里删除对应的残留生成物。这很可能解释了为什么已发布的 CLI 固定在一个未合入 main 的 SDK 伪版本上——那条分支的 vendored spec 被手工修过。
验证
go build ./...通过go test ./...全绿,含TestSpecExamplesRoundTrip(它抓出了 diagnose 示例把 RFC 3339 时间写成 unix 整数的问题,已在 docs 侧修正)第二个提交:稀疏字段不再被物化成零值
原先的判断是「根因在生成器策略、另案处理」,这个判断是错的。生成器早就支持
x-flashduty-preserve-absence(internal/cmd/gen/main.go)——只是 monit 那几个字段在 spec 里没标。docs #190 补上标记后,本次重新生成的结果:改 spec 而不动生成器默认策略,是因为「响应值类型不加 omitempty」对其余 583 个 schema 是对的(
enabled=false必须忠实渲染)。影响面精确限于标记过的 10 个字段,models_gen.go的 diff 是 10 增 10 删,零附带变化。Params、Tool和两个 elapsed 计数器保持值类型——webapi 总会发它们。遗留(未包含在本 PR)
zz_generated_response_help.go的Diagnostics.TargetsList把data记成顶层数组,实际是{items,total}——存量错误,与 monit 契约无关,另案第三个提交:
target_kinds审查发现第二个提交漏了一个字段:标记加在父级
error对象上,但生成器只认字段自身的标记。TargetKinds因此仍是[]string无 omitempty,CLI 在每个错误响应上凭空补出"target_kinds": null。现为
*[]string+ omitempty。真实 dev 复验:target_unavailable路径下 CLI 输出与 webapi 裸线逐键一致。