feat(atomize): serve Subdivide via Anypreta Issue Atomizer
Add an optional remote atomization backend (the Anypreta "Issue Atomizer"
API) for the Subdivide flow, selected by ATOMIZER_REMOTE_BASE_URL /
ATOMIZER_REMOTE_API_KEY. When set, POST /v1/atomize is served by the remote
/v1/atomize-issue endpoint; its two-level issue→features→tasks model is mapped
onto our one-level task→children model by treating each Feature as a child and
its `estimation` as the effort coefficient (renormalized to sum to 1, even
split as a reported fallback when estimations are absent).
Extend and Summarize have no counterpart in the remote API and always stay on
ATOMIZER_BASE_URL, so the §5.1 service must keep running; readiness now probes
both backends. The mandatory `system` object is derived from the customer,
with a generic component tree (an empty tree makes the service return zero
features).
extsvc also learns the remote's flat error envelope ({error_code,message} and
FastAPI {detail}) and never swallows an unrecognized 4xx body.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -121,13 +121,34 @@ func (c *Client) callOnce(ctx context.Context, method, path string, in, out any)
|
||||
if resp.StatusCode >= 400 {
|
||||
se := &ServiceError{Status: resp.StatusCode}
|
||||
var env struct {
|
||||
// §5 envelope: {"error":{"code":…,"message":…}}.
|
||||
Error struct {
|
||||
Code string `json:"code"`
|
||||
Message string `json:"message"`
|
||||
} `json:"error"`
|
||||
// Flat envelope, used by the Anypreta atomizer:
|
||||
// {"error_code":…,"message":…}. FastAPI's own validation
|
||||
// errors carry {"detail":…} instead.
|
||||
ErrorCode string `json:"error_code"`
|
||||
Message string `json:"message"`
|
||||
Detail json.RawMessage `json:"detail"`
|
||||
}
|
||||
if json.Unmarshal(data, &env) == nil {
|
||||
se.Code, se.Message = env.Error.Code, env.Error.Message
|
||||
if se.Code == "" {
|
||||
se.Code = env.ErrorCode
|
||||
}
|
||||
if se.Message == "" {
|
||||
se.Message = env.Message
|
||||
}
|
||||
if se.Message == "" && len(env.Detail) > 0 {
|
||||
se.Message = string(truncate(env.Detail, 200))
|
||||
}
|
||||
}
|
||||
if se.Message == "" {
|
||||
// Never swallow the failure: an unrecognized envelope still
|
||||
// has to reach the logs and the consultant's error toast.
|
||||
se.Message = string(truncate(data, 200))
|
||||
}
|
||||
return se // 4xx is not retryable
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user