Skip to content

fix(sdk-generator): re-export the runtime timeout surface from the package root - #104

Merged
rob-archastro merged 1 commit into
mainfrom
fix/python-package-init-runtime-exports
Sep 16, 2026
Merged

rob-archastro merged 1 commit into
mainfrom
fix/python-package-init-runtime-exports

Conversation

@rob-archastro

@rob-archastro rob-archastro commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Review on ArchCode

Problem and author intent

platform/__init__.py is generated, and its header reads "auto-generated by @archastro/sdk-generator. Do not edit." The generator emitted re-exports for the client, versions and auth — but not for the runtime's timeout surface.

request_timeout is the documented way to bound a generated call: the README teaches importing it from the package root, and callers thread a remaining deadline through it. Because the generator never emitted that import, the export in archastro-python existed only because it had been added by hand to that do-not-edit file (archastro-python@c7ef03a7).

The first regeneration since then removed it, exactly as designed, and broke the public import:

ImportError: cannot import name 'DEFAULT_TIMEOUT_S' from 'archastro.platform'
tests/test_http_client.py::test_generated_resource_methods_honor_request_timeout

That guard test was written alongside the hand edit and carries the comment "a regeneration that drops the re-export fails here" — it is the only thing that detected this, and it could not fire until a regeneration actually ran. The hand edit also left the file's Content hash header untouched, so no hash comparison could reveal the drift either.

What changed

generatePackageInit now emits the runtime re-export alongside the existing client re-export:

from .client import AsyncPlatformClient, PlatformClient  # noqa: F401
from .runtime.http_client import DEFAULT_TIMEOUT_S, request_timeout  # noqa: F401

This makes a documented public import part of generated output, so it survives regeneration and is covered by the content hash rather than depending on a hand edit that the next regeneration silently removes.

runtime/http_client.py itself is unchanged and stays hand-maintained — this only changes what the generated package re-exports from it.

Scope and risk

Generator-only; one function in backends/python/index.ts. Python backend only.

Risk: low. The change is additive — one import line in the generated package root. Every downstream SDK already ships this runtime module, so the import always resolves.

Testing

New test re-exports the runtime timeout surface from the package root asserts the emitted platform/__init__.py contains the import.

Full generator suite: 424 passed (12 files), tsc clean, eslint clean.

End-to-end: regenerating the real 260-route platform spec emits the re-export and all 37 generated modules still pass python -m py_compile. The emitted file's content hash moves from d14486b6976e to 2b92e5dbd287, which is the point — the export is now hash-covered content rather than an invisible hand edit.

Follow-ups

No version bump here, per this repo's convention. A sdk-generator release is needed before archastro-python can regenerate green; its regen PR is currently red on precisely this import.

🤖 Generated with Claude Code

https://claude.ai/code/session_013CN15q1LWb444eMZSkQi9M

…ckage root

`request_timeout` is the documented way to bound a generated call, and the
README teaches importing it from the package root. It lives in the
hand-maintained runtime, and the generated `platform/__init__.py` did not
re-export it — so the export only existed because it had been added by hand to
a file whose header reads "auto-generated ... do not edit".

The first regeneration since then removed it, breaking
`from archastro.platform import DEFAULT_TIMEOUT_S, request_timeout` and failing
the guard test that exists for exactly this case. The hand edit also left the
file's `Content hash` untouched, so nothing else could detect the drift.

Emit the re-export so the public import survives regeneration and is covered by
the content hash.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013CN15q1LWb444eMZSkQi9M
@rob-archastro
rob-archastro merged commit a265e8c into main Sep 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant