Files
zeekay 497f5fe433 the C++ client lands: 2376 translation units, 0 fail
This repo carried a refusal — the seam, the CI gates and the template overrides,
but no client, because no openapi-generator 7.14.0 C++ generator emitted a tree
that compiled from hanzo.yaml. That was true and is no longer.

WHAT CHANGED, in the order it mattered:

  * openapi-generator 7.24.0 instead of 7.14.0. The 10 translation units the
    previous measurement could not fix were two defects in the generator's own
    Java type resolution, and mustache cannot reach either — it interpolates the
    strings resolution produces, it cannot recompute a type. 9 TUs were
    `additionalProperties: {$ref: <array-typed schema>}` dropping the aliased
    array's element type (`std::map<utility::string_t, std::vector>`, never
    valid C++); 1 was an integer-backed enum declared over utility::string_t and
    defined over int32_t. Both are fixed upstream in 7.24.0. The floor is stated
    once, in scripts/generate.sh, with the measurement — a row in sdks.yaml says
    one version for EVERY language, and raising the fleet pin would rewrite
    every other client's committed output.

  * The four template overrides re-derived from 7.24.0 stock rather than merged
    onto it, so a future bump re-derives them again. 7.24.0 fixed two of the
    five defect classes the 7.14.0 overrides carried; it also has two of its own
    in the enum path, both template-shaped: isPrimitiveType and isEnum are not
    exclusive, so an integer-backed enum declared its setter twice and defined
    it once, and the conversion helpers disagreed between header and source.

  * -DmaxYamlCodePoints. hanzo.yaml crossed snakeyaml's 3145728 code-point
    ceiling (3,654,449 at spec 1bac13f) and the failure does not say so: the
    parser logs SnakeException, silently falls through to the SWAGGER 2.0 compat
    reader, and dies with "Issues with the OpenAPI input", which reads like a
    malformed spec. The document validates at 0 errors and 0 warnings. This is
    fleet-wide, so it is also set in hanzoai/openapi's generate.py, once, where
    every language picks it up.

WHAT IS HERE NOW: include/hanzo (2377 headers, 264 API classes, 2103 models) and
src (2376 sources), the hanzo::hanzo CMake target with its install/export set,
and the six canonical flows from hanzoai/openapi's flows.yaml — hello, chat,
money, store, agent, tools — each compiled by the examples gate, resolving
HANZO_API_KEY / HANZO_BASE_URL / HANZO_ORG_ID in ONE place rather than six.

The generator's CMakeLists.txt and Config.cmake.in are dropped before the tree
lands: the target name, the export set and HANZO_BUILD_EXAMPLES are this repo's
contract with a consumer, not a generator artifact.

CI is wired and UNEXERCISED — hanzoai/ci defaults to the hanzo-build-linux-amd64
arc pool, which has zero registered runners, so a run queues rather than
executes. Every number above is from a clean-clone local build on aarch64
Ubuntu 24.04, g++ 13.3, cmake 3.28.3, cpprestsdk 2.10.19, against
hanzoai/openapi@1bac13fb75.
2026-07-31 14:45:03 -07:00

40 lines
1.3 KiB
C++

// The one place the six examples resolve their environment.
//
// HANZO_API_KEY is required, HANZO_BASE_URL defaults to https://api.hanzo.ai,
// and HANZO_ORG_ID carries the org that the KV and agent routes refuse to
// answer without. Every flow calls client(); none of them reads getenv itself.
#ifndef HANZO_EXAMPLES_H_
#define HANZO_EXAMPLES_H_
#include <memory>
#include <string>
#include "hanzo/ApiClient.h"
namespace hanzo {
namespace examples {
// A client authenticated as HANZO_API_KEY against HANZO_BASE_URL.
// Throws std::runtime_error when the key is missing.
std::shared_ptr<api::ApiClient> client();
// https://api.hanzo.ai unless HANZO_BASE_URL says otherwise.
utility::string_t baseUrl();
// The model the chat and agent flows ask for; HANZO_MODEL overrides.
utility::string_t model();
// Print one labelled line. Every flow reports through this, so the six read the
// same way whichever language a reader arrives from.
void print(const utility::string_t& label, const utility::string_t& value);
void print(const utility::string_t& label, int64_t value);
// Turn any exception into the process's exit code, printing an ApiException's
// status and body rather than just its what().
int fail(const utility::string_t& what, const std::exception& e);
} // namespace examples
} // namespace hanzo
#endif // HANZO_EXAMPLES_H_