Skip to content

Sync Sakura AI Engine models automatically - #108

Merged
dceoy merged 13 commits into
mainfrom
feat/sync-sakura-models
Aug 25, 2026
Merged

Sync Sakura AI Engine models automatically#108
dceoy merged 13 commits into
mainfrom
feat/sync-sakura-models

Conversation

@dceoy

@dceoydceoy commented Aug 25, 2026

Copy link
Copy Markdown
Owner

Summary

  • add a shell-based Sakura AI Engine model discovery/sync script
  • probe /v1/chat/completions to keep only OpenCode-usable chat models
  • add a daily/manual workflow that opens or updates a PR when the model set changes
  • use the repository-provided GITHUB_TOKEN with contents: write and pull-requests: write to create sync PRs
  • fail closed on invalid model listings, authentication/rate-limit errors, transport errors, and server errors
  • add Bats coverage for model filtering/order and empty-list safety

Configuration

The scheduled workflow requires only the repository secret SAKURA_AI_ENGINE_API_KEY. It uses the workflow GITHUB_TOKEN for repository writes and pull request creation; no GH_TOKEN or personal access token is required.

Because GitHub suppresses new workflow runs for events triggered by GITHUB_TOKEN, sync PRs created by this workflow do not automatically trigger pull_request workflows.

Validation

  • bash -n scripts/sync-sakura-models.sh
  • mocked normal sync updates only the Sakura models block and preserves the rest of opencode.jsonc
  • mocked empty /v1/models response exits non-zero without modifying the config

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:e7b2ae35ef

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadscripts/sync-sakura-models.sh Outdated
Comment threadscripts/sync-sakura-models.sh

@claudeclaudeBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consolidated review from two automated passes (pr-review-toolkit: code/comments/tests/errors/types, run in parallel, plus Claude Code's security-review with adversarial false-positive filtering). All findings below were independently verified against the current PR diff and surrounding code (including cross-checking .github/workflows/opencode-bot.yml and run-opencode.sh). No high-confidence security vulnerabilities survived the adversarial filtering pass — two candidates (an awk brace-depth desync from crafted model IDs, and unsanitized model IDs in log output) were both excluded as speculative / not concrete security issues (the latter also falls under standard "log spoofing is not a vulnerability" guidance), though the underlying brace-depth fragility is noted below as a correctness issue. Remaining items are correctness/robustness and test-coverage gaps, left as inline comments. Nice to see the fail-closed design intent (empty-listing guard, set -euo pipefail, pinned action SHAs, scoped workflow permissions, no pull_request trigger) — the comments below are refinements on top of that, not blockers to the overall approach.

Comment threadscripts/sync-sakura-models.sh Outdated
Comment threadscripts/sync-sakura-models.sh Outdated
Comment threadscripts/sync-sakura-models.sh Outdated
Comment threadscripts/sync-sakura-models.sh
Comment threadtests/test-sync-sakura-models.bats Outdated
@dceoydceoy self-assigned this Aug 25, 2026
@opencode-agent

Copy link
Copy Markdown

The trusted-context validation gate has failed:

::error::Pinned review context is unavailable or invalid, or the PR head changed.

Per the pr-review skill's fail-closed rules ("Once context succeeds, any later metadata, diff, or validation failure must abort the review"; "If validation fails, stop"), I am aborting this review run.

Review status: aborted — no findings published.

  • Discovery and independent validation completed across all 3 changed files (.github/workflows/sync-sakura-models.yml, scripts/sync-sakura-models.sh, tests/test-sync-sakura-models.bats) against pinned head e7b2ae35efe8dbe0387c559c79ac99cac71d5bcd.
  • 5 candidate findings passed independent validation (2 important: string-blind brace counting in the awk JSONC splice, and curl --retry corrupting captured status/body on recovered transients; 3 suggestions: multi-"models"-block replacement scope, wasted auth-failure retries, and an uncovered empty-model-list guard).
  • Because the pre-submission validation gate now reports the pinned review context as unavailable/invalid or the head SHA as changed, submitting inline findings can no longer be safely anchored to a verified head commit, so nothing was written to the pull request.

New%20session%20-%202026-08-25T15%3A19%3A56.423Z
opencode session | github run

@dceoydceoy left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the current head (cdb79441a1b96f1b0b40f832aa34de7d16622898). The earlier provider-scoping, partial-extraction, default-model, and failure-path coverage issues are addressed. One correctness issue remains in the probe classification below.

Comment threadscripts/sync-sakura-models.sh Outdated

@dceoydceoy left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found one merge-blocking functional issue in the production model-classification path. CI is green, but the normal mock does not reproduce Sakura's mixed model listing.

Comment threadscripts/sync-sakura-models.sh

@dceoydceoy left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed current head 52cc515aee909b7e6457fefc9e6d88159bd5ccd6. The previously reported provider-scoping, partial-extraction, default-model, ambiguous-4xx, and mixed non-chat-model issues are addressed, and CI is green. I found one remaining operational correctness issue: the documented minimal configuration can create sync PRs whose CI does not run automatically.

Comment thread.github/workflows/sync-sakura-models.yml Outdated

@dceoydceoy left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found one configuration issue that should be fixed before relying on the scheduled sync. CI is currently green, and the previously reported model-filtering/default-model issues are addressed in the current head.

Comment threadREADME.md Outdated

@dceoydceoy left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed current head 145d1164a0be5ccb4087d6676d00ca1d3c026620. CI is green and the previously reported functional issues are addressed. I found one remaining least-privilege issue in the scheduled workflow.

Comment thread.github/workflows/sync-sakura-models.yml Outdated

@dceoydceoy left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed current head ceb40d809d8e74cbf513d97dd8266bed6826e01a. The previously reported provider scoping, partial extraction, default-model consistency, ambiguous probe handling, mixed non-chat model handling, dedicated-token configuration, and least-privilege issues are addressed. CI is green, including Bats, shell lint, and GitHub Actions lint/scan. I found no additional high-confidence merge blockers in the current diff.

@dceoy
dceoyforce-pushed the feat/sync-sakura-models branch from 3a8a135 to 26edfaaCompareAugust 25, 2026 17:49
@dceoy
dceoy merged commit 18846c5 into mainAug 25, 2026
14 checks passed
@dceoy
dceoy deleted the feat/sync-sakura-models branch August 25, 2026 17:51
Sign up for freeto 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.

2 participants

@dceoy@claude