Commit Graph

11 Commits

Author SHA1 Message Date
Hongming Wang
7c3aeb5a14 ci: install pyyaml so the YAML-loading test path is exercised
Without pyyaml in CI, adapter._load_providers' broad except-Exception
swallows the ImportError and silently falls back to _BUILTIN_PROVIDERS.
Tests then assert 7 providers but get 2; setup() can't route any
third-party model. Locally pyyaml is system-installed so the issue
went unnoticed.

Same failure mode as the 2026-04-30 incident (CI green, prod broken)
— pinning the dep here closes that gap.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-30 23:40:47 -07:00
Hongming Wang
61f935674f
Merge branch 'main' into feat/adapter-prevalidate 2026-04-30 22:38:53 -07:00
Hongming Wang
0d95b5098a feat(adapter): pre-validate ANTHROPIC_BASE_URL + missing model combo
The 2026-04-30 staging incident traced back to workspaces booting with
ANTHROPIC_BASE_URL pointing at a non-Anthropic shim (MiniMax / OpenAI
gateway) but no explicit model configured. The adapter silently fell
back to "sonnet" — an Anthropic-native alias the upstream didn't
recognize — and the SDK --print probe hung 30s before timing out.
Platform's phantom-busy sweep then nuked the workspace at 10min,
producing "every workspace dead" with the root cause buried in a
30s subprocess hang.

Pre-validate the combo at adapter boot: when ANTHROPIC_BASE_URL host
is non-Anthropic AND no explicit model is set, raise ValueError with
an actionable message pointing to MODEL_PROVIDER / runtime_config.model.
Also log the resolved model + base_url_host every boot so future
failures explain themselves in the workspace logs without digging
into the SDK subprocess.

Tests live under tests/ with their own pytest.ini that anchors rootdir
there — keeps pytest from importing the package __init__.py (which
does the runtime-discovery relative import that requires
molecule_runtime installed). 7 tests cover: misconfig raises with the
right message, Anthropic-native passes, no-base-url passes, custom-url
+ explicit model passes, dataclass + dict shapes, unparseable URL
no-crash. CI runs them on every push/PR.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-30 22:35:49 -07:00
Hongming Wang
4af6cd612a
Merge branch 'main' into chore/enroll-secret-scan 2026-04-29 13:46:33 -07:00
Hongming Wang
3531f19668 fix(publish-image): drop pull_request trigger — leaks PR builds to GHCR
`on: pull_request:` was the only template-repo with this trigger
out of the 8 (other 7 trigger only on push:main, repository_dispatch,
workflow_dispatch). The reusable publish-template-image workflow has
no PR-skip guard, so the PR trigger fired every time a PR was opened
or updated and pushed both `:latest` (clobbering the production tag
with unmerged code) and `:sha-<7>` (a stable tag for an unmerged
commit) to GHCR.

Verification at PR time already happens via the
validate-workspace-template workflow's "Docker build smoke test"
step, which builds the image but does NOT push. That's the right
place for PR-time verification.

Removing the trigger here aligns claude-code with the canonical 7
templates and stops the GHCR leak.

While here, updated the runtime_version comment to drop the now-
stale "/PR" reference.
2026-04-27 15:15:46 -07:00
Hongming Wang
de2ab5ab33 feat: forward client_payload.runtime_version + ARG RUNTIME_VERSION
Closes the cache trap structurally (instead of pin-bumping every
runtime release):
1. publish-image.yml caller now forwards
   github.event.client_payload.runtime_version (set by cascade) to
   the molecule-ci reusable workflow as runtime_version input.
2. Reusable workflow forwards it to docker build as a --build-arg.
3. Dockerfile declares ARG RUNTIME_VERSION near the pip install
   layer so its value becomes part of the cache key.
4. The pip install RUN command does an extra targeted upgrade to
   the exact version when ARG is set — guarantees the version is
   what we expect even if requirements.txt resolves to something
   else.

Pairs with molecule-ci PR #12 + molecule-core PR #2181. Together
the pipeline is now race- and cache-proof end-to-end.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 07:46:14 -07:00
rabbitblood
8e905cda0d chore(ci): enroll in org-wide secret-scan reusable workflow (Molecule-AI/molecule-core#2109) 2026-04-26 20:09:02 -07:00
Hongming Wang
13eadcc158
ci(publish-image): accept repository_dispatch from monorepo runtime publish (#10)
Adds 'repository_dispatch' trigger (event-type: runtime-published) so
molecule-core's publish-runtime.yml cascade job can fire this template's
image rebuild after a new molecule-ai-workspace-runtime PyPI release.

Without this, every runtime release waited for the next push: main /
manual workflow_dispatch to propagate to the published image. With it,
runtime fixes flow monorepo → PyPI → all 8 template images
automatically.

Part of the runtime CD chain. See molecule-core docs/workspace-runtime-package.md.

Co-authored-by: Hongming Wang <hongmingwangalt@gmail.com>
2026-04-26 12:42:19 -07:00
8250fd0008 fix(ci): add pull_request trigger to publish-image workflow
Branch protection on main requires the publish / Build & push template
image check to pass for all PRs. The workflow previously only triggered
on push to main, so PRs could never satisfy branch protection.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-04-23 05:37:16 +00:00
molecule-ai[bot]
2ef87f2f23
fix(security): remove .auth-token API key from git history
The .auth-token file committed in b8859da contains a live API key.
Remove it from git history and add CI publish-image workflow.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-23 00:06:36 +00:00
Hongming Wang
1b4ee8e225 ci: add standard workspace template validation workflow 2026-04-16 04:43:13 -07:00