Repository navigation
feat(infra): add the studuino hex compile lambda (container + http api) - #2278
Merged
smalruby3-editor-bot[bot] merged 5 commits intoNov 19, 2026
Merged
Conversation
Add a new CDK project infra/smalruby-studuino-hex: a container Lambda with arduino-cli, the AVR core and (when the official zip is pinned) the Studuino library, behind an HTTP API with POST /compile. This stage only compiles fixed samples (blink / studuino-led). - Versions and hashes are pinned in container/third-party.json - Origin check in the handler (403), 128KB body (413), per-IP 12/min and 600/day in DynamoDB (429), compile cut-off (504) - One EMF log line per request (Smalruby/StuduinoHex metrics) - CI jobs in ci-infra.yml, shared CORS copy, docs/infra page Refs #2209 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🚀 Preview deployed (stg API): https://preview.smalruby.app/feat-studuino-hex-lambda-2209-1de87c4b/ |
- Board: install Artec's Arduino IDE 1.6.x/1.8.x board definition (studuino:avr:studuino, atmega168 8MHz, max 15872 bytes) from the official zip, pinned by sha256. Fall back to arduino:avr pro 168 8MHz and report boardError if it cannot be fetched or verified. - Studuino library: pin the sha256 of studuino_v1_lib.zip; the URL is a candidate under the same data/ path and is verified by sha256. If it fails, build without the library and report studuinoLibError. - Samples: add robot-car (medium) and smalrubot-s1 (large, the MIT sr_studu firmware) to measure compile time; samples may have several files. Add Adafruit NeoPixel 1.15.2. - Response: add coldStart and the board / library errors to toolchain. Refs #2209 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #2209 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🚀 stg にデプロイしました:
stg は共有環境です。この SHA が載っている前提で 動作確認してください。
|
|
🚀 stg にデプロイしました:
stg は共有環境です。この SHA が載っている前提で 動作確認してください。
|
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #2209
なにをしたか
Studuino モードの hex を作る Lambda の土台を、新しい CDK プロジェクト
infra/smalruby-studuino-hexとして足しました(🧱 infra・追加だけ)。arduino:avr@1.8.8・Servo 1.2.2・Studuino ライブラリ(5 つ)POST /compile: この段階では決まったサンプル(blink/studuino-led)だけをコンパイルして hex を返す(任意の C++ は受け付けない。構文木は feat(infra): hex を作る Lambda に構文木(Studuino IR)の検査と C++ の書き出しを足す #2210)infra/shared/cors-origins.tsのresolveCorsOrigins。prod はhttps://smalruby.appだけ、stg はローカルとブランチプレビューも)+ハンドラでも検査して許可外・Origin なしは 403Retry-After)・コンパイルの打ち切り(504)・API 全体のスロットリングSmalruby/StuduinoHex(Requests / Succeeded / Failed / Rejected / CompileTime / HexBytes など)docs/studuino-mode/README.md(topic/studuino-2163)の「Lambda の API」に合わせた(hex/size/maxSize/source/toolchain、errorの名前と HTTP)決めたこと(AI の推奨)
smalruby-studuino-hexDeploy Infraはcdk.jsonのあるディレクトリを自動で拾い、bin/sync-worktree-envもinfra/*/.env.*を走査するので変更不要POST /compile/studuino/hexは仮)studuino:avr:studuino(arduino_ide_settings_ver16x_18x.zipのother/hardware/studuino)、上限 15,872 バイトmcu=atmega168・f_cpu=8000000L・build.board=AVR_PRO・upload は optiboot(arduino・115200bps)・maximum_size=15872。コアとツールはarduino:avr。いまの書きこみ(シグネチャ1E 94 06・115200bps)とも合う。1.7.x 用は Arduino IDE 1.7(arduino.org 版)向けなので使わない。取れない・sha256 が合わないときはarduino:avr:pro:cpu=8MHzatmega168(上限 14,336)で作り、toolchain.boardErrorに理由を出すcontainer/third-party.jsonだけで固定 → CDK が build args で渡すhttps://www.artec-kk.co.jp/studuino/data/studuino_v1_lib.zip(sha256 は人間の手元のstuduino_v1_lib.zipと同じad0e4aaf…)data/の下と見た推定だったが、stg のコンテナのビルドで取れて sha256 も一致した(応答のtoolchain.studuinoLib)。取れない・合わないときはライブラリなしで作り、studuinoLibErrorに理由を出す(イメージのビルドは止めない)/tmpへ写すrateLimitFailOpen).claude/rules/infra/development.md)execute-apiのエンドポイント)取得元(アーテック社の公式の配布元)
7cb02225…084cfad0e4aaf…ee219コンテナ(devcontainer の egress firewall)からは artec-kk.co.jp につながらないので、手元の zip(
tmp/to-ai-files/studuino/)を scratchpad で展開して中身を確かめた。ファイルはリポジトリにも GitHub にも載せていない(URL と sha256 だけ)。テスト
infra/smalruby-studuino-hexの jest(7 ファイル・79 件): 上限・Origin・回数の窓・応答の形・EMF のメトリクス(policy)、ハンドラ(403 / 413 / 429 / 400 / 422 / 504 / fail-open / base64 / コールドスタート)、スタック(Lambda・ルート・CORS・スロットリング・TTL・ログの保存期間・prod の CORS)、third-party.jsonnpm run build・cdk synthを stg / prod で通した(synth はイメージを作らない)stg の結果(commit
dd860e95。PR の「🚀 stg にデプロイしました」コメントで確認)Deploy Infraの[smalruby-studuino-hex] deploy stgは約 3 分(イメージのビルドを含む)で成功した。コンパイルの時間(サンプルごと・各 2 回)
blink(コアだけ)studuino-ledrobot-carsmalrubot-s1(S1 のファームウェア)compileMs)。応答は手元から測った全体の時間。コールドは同時に 8 本送って新しい実行環境で測った(応答のcoldStart: true)。REPORTのInit Duration)は平均 0.80 秒・最大 0.97 秒。メモリの最大は 425MB(2GB 中。CPU の速さのため 2GB のままにした)。downloads.arduino.cc)が egress firewall で取れない。Issue の「テスト」の項目
toolchainにボード定義とライブラリの sha256)forbidden_origin(Origin なしも 403)too_largerate_limited・Retry-After: 20(その前の計測の呼び出しも同じ窓で数えられている)event: "studuino_hex_request"(Logs Insights で outcome × coldStart: ok 16・rate_limited 9・invalid_request 5・forbidden_origin 2・too_large 1)Smalruby/StuduinoHexに Requests / Succeeded / Failed / Rejected / CompileTime / HexBytes / RequestBytes / TotalTime人間の作業・確認
INFRA_STG_DOTENV_SMALRUBY_STUDUINO_HEX・EnvironmentprodのINFRA_PROD_DOTENV_SMALRUBY_STUDUINO_HEX(登録済み).claude/rules/infra/development.mdの Projects 表と.claude/rules/infra/smalruby-studuino-hex.md(AI は.claude/を編集しない決まりのため。中身はdocs/infra/smalruby-studuino-hex.mdを写せばよい)blink・studuino-ledは A0 の LED が 0.5 秒ごとに点滅(8MHz の想定が合っていれば 0.5 秒。16MHz なら 1 秒に見える)。smalrubot-s1はいまのファームウェアと同じ働き(書きこんだあと通常モードでつながる).github/workflows/ci-infra.ymlの変更(3 ジョブ)のレビュー(Bot の権限外のパス)smalrubot-s1は smalruby/smalrubot のsr_studu(MIT、フォルダに LICENSE)を写したもの。Adafruit NeoPixel は同梱せず arduino-cli で 1.15.2 を入れる(元の同梱版より新しい)🤖 Generated with Claude Code