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:
etalon
2026-07-15 17:49:41 +02:00
parent 39ec958f04
commit 33c9c39676
9 changed files with 613 additions and 10 deletions
+22 -7
View File
@@ -54,9 +54,14 @@ type Config struct {
AdminEmail string
AdminInitialPassword string
AtomizerBaseURL string
AtomizerToken string
AtomizerTimeout time.Duration
AtomizerBaseURL string
AtomizerToken string
AtomizerTimeout time.Duration
// AtomizerRemoteBaseURL / AtomizerRemoteAPIKey enable the Anypreta Issue
// Atomizer as the Subdivide backend. Both must be set; Extend and
// Summarize stay on ATOMIZER_BASE_URL either way.
AtomizerRemoteBaseURL string
AtomizerRemoteAPIKey string
WorkPerformerBaseURL string
WorkPerformerToken string
WorkPerformerHTTPTimeout time.Duration
@@ -115,10 +120,12 @@ func Load() (*Config, error) {
AdminEmail: strings.ToLower(strings.TrimSpace(getenv("ADMIN_EMAIL", ""))),
AdminInitialPassword: os.Getenv("ADMIN_INITIAL_PASSWORD"),
AtomizerBaseURL: strings.TrimRight(getenv("ATOMIZER_BASE_URL", "http://atomizer-mock:8090"), "/"),
AtomizerToken: os.Getenv("ATOMIZER_TOKEN"),
WorkPerformerBaseURL: strings.TrimRight(getenv("WORK_PERFORMER_BASE_URL", "http://work-performer:8091"), "/"),
WorkPerformerToken: os.Getenv("WORK_PERFORMER_TOKEN"),
AtomizerBaseURL: strings.TrimRight(getenv("ATOMIZER_BASE_URL", "http://atomizer-mock:8090"), "/"),
AtomizerToken: os.Getenv("ATOMIZER_TOKEN"),
AtomizerRemoteBaseURL: strings.TrimRight(os.Getenv("ATOMIZER_REMOTE_BASE_URL"), "/"),
AtomizerRemoteAPIKey: os.Getenv("ATOMIZER_REMOTE_API_KEY"),
WorkPerformerBaseURL: strings.TrimRight(getenv("WORK_PERFORMER_BASE_URL", "http://work-performer:8091"), "/"),
WorkPerformerToken: os.Getenv("WORK_PERFORMER_TOKEN"),
SMTP: SMTP{
Host: os.Getenv("SMTP_HOST"),
@@ -155,6 +162,14 @@ func Load() (*Config, error) {
fail("%s: %q is not an absolute URL", name, v)
}
}
if c.AtomizerRemoteBaseURL != "" {
if u, err := url.Parse(c.AtomizerRemoteBaseURL); err != nil || u.Scheme == "" || u.Host == "" {
fail("ATOMIZER_REMOTE_BASE_URL: %q is not an absolute URL", c.AtomizerRemoteBaseURL)
}
if c.AtomizerRemoteAPIKey == "" {
fail("ATOMIZER_REMOTE_API_KEY: required when ATOMIZER_REMOTE_BASE_URL is set")
}
}
if len(c.SessionSecret) < 16 {
fail("SESSION_SECRET: must be at least 16 characters of random data")
}